Skip to main content

Babylon Staking Indexer

The Babylon Staking Indexer is a tool that extracts staking-relevant data from both the Babylon blockchain and the Bitcoin blockchain. It processes, validates, and stores staking transactions while gathering data about their status. This indexer serves as a data aggregation and transformation layer, making blockchain data available in an API-friendly format for dApps to use.

Hardware Requirements

  • CPU: Multicore processor (4 cores minimum)
  • Memory: Minimum 4GB RAM (recommended 8GB RAM)

Configuration

1. Create Home Directory

mkdir -p ~/.babylon-staking-indexer/

2. Copy the Default Configuration

cp ~/babylon-staking-indexer/config/config-local.yml ~/.babylon-staking-indexer/config.yml

3. Update Default Configurations

Edit the config.yml file to match your environment:

MongoDB Cluster Connection

Set the MongoDB connection address (address) and credentials (username, password, and db-name) to match the information from your installed MongoDB cluster.

db:
address: "mongodb://localhost:27019/?replicaSet=RS&directConnection=true"
username: "root"
password: "example"
db-name: "babylon-staking-indexer"

Bitcoin Node Connection

Configure the Bitcoin node connection details to match your Bitcoin node installation.

btc:
rpchost: 127.0.0.1:38332
rpcuser: rpcuser
rpcpass: rpcpass
netparams: signet

Babylon Node Connection

Set the Babylon RPC address and connection parameters.

bbn:
rpc-addr: https://rpc-dapp.devnet.babylonlabs.io:443
timeout: 30s

RabbitMQ Cluster Connection

Set the RabbitMQ connection address (url) and credentials (queue_user and queue_password) to match the information from your installed RabbitMQ cluster.

queue:
queue_user: user
queue_password: password
url: "localhost:5672"
queue_type: quorum

Prometheus Metrics Configuration

Set the host and port to customize how the metrics are exposed.

metrics:
host: 0.0.0.0
port: 2112

Start the Service

Runs the Babylon Staking Indexer image from the official Docker Hub repository:

docker run -d --name babylon-staking-indexer \
-v ~/.babylon-staking-indexer/config.yml:/app/config.yml \
babylonlabs/babylon-staking-indexer:v1.0.0 --config /app/config.yml

This approach is recommended for production environments as it provides better isolation and simplified deployment.

Method B: Local Binary Execution

1. Clone the Repository

git clone https://github.com/babylonlabs-io/babylon-staking-indexer.git

2. Check Out the Desired Version

You can find the latest release here.

cd babylon-staking-indexer
git checkout tags/{VERSION}

3. Install the Binary

make install

This command will build and install the binary to your GOPATH.

4. Start the Indexer

You can start the Staking Indexer by running:

babylon-staking-indexer --config ~/.babylon-staking-indexer/config.yml

Create Systemd Service (Linux Only)

1. Create Systemd Service Definition

Run the following command, replacing system_username with the appropriate system user or service account name:

cat <<EOF | sudo tee /etc/systemd/system/babylon-staking-indexer.service
[Unit]
Description=Babylon Staking Indexer service
After=network.target

[Service]
Type=simple
ExecStart=$(which babylon-staking-indexer) --config /home/system_username/.babylon-staking-indexer/config.yml
Restart=on-failure
User=system_username

[Install]
WantedBy=multi-user.target
EOF

2. Reload Systemd Configuration

sudo systemctl daemon-reload

3. Enable the Service at Boot

sudo systemctl enable babylon-staking-indexer.service

4. Start the Service

sudo systemctl start babylon-staking-indexer.service

5. Verify the Service

Check service status:

sudo systemctl status babylon-staking-indexer.service

Expected log output will confirm the service is active.

Monitoring

The service exposes Prometheus metrics through a Prometheus server. By default, it is available at the address configured in the metrics configuration section (0.0.0.0:2112). Configure the metrics endpoint in your configuration file as needed.

Backup

The Babylon Staking Indexer is stateless, so no backups are needed.