Babylon PoS

Unified API + Babylon PoS (BABY) Integration Workflow

In the following guide, the integration process for the babylon chain is covered. The BABY integration aligns with the general Unified API process but with network-specific parameters.

Get an authentication token to start using the Unified API.

Request examples are provided using cURL.

To check the integration guides for other chains, refer to the Networks section.

📘

Key BABY-specific details

  • chain — always set to babylon for BABY-related requests.
  • network — environment in which the transaction is processed (testnet or mainnet).
  • stashAccountAddress — Babylon account address performing the action.
  • amount — amount to stake/unstake (in BABY, integer).
  • validatorAddress — validator receiving the delegation (optional if default).
  • rewardDestinationAddress — address where staking rewards are sent (defaults to stash account).
  • transactionData— returned object with encoded transaction, messages, fee, and hashes for signing.

Staking Flow

1. Create Bond Request

Send a POST request to /api/v1/unified/staking/stake.

Example request (for testnet network):

curl --request POST \
     --url https://api-test.p2p.org/api/v1/unified/staking/stake \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <token>' \
     --data '{
    "chain": "babylon",
    "network": "babylon-testnet",
    "stakerAddress": "bbn1pq0w7wedwvgttv4zjr99kx6n6e8ennu9xevztg",
    "amount": 0.1
}'
  • chain — blockchain network, always set to babylon for Babylon-related requests.
  • network — environment in which the transaction is processed (babylon-mainnet or babylon-testnet).
  • stakerAddress — Babylon account address initiating the bonding transaction.
  • amount — amount of tokens to bond. BABY is used for the mainnet network.

Example response:

{
    "error": null,
    "result": {
        "amount": 0.1,
        "unsignedTransactionData": {
            "messages": [
                {
                    "typeUrl": "/babylon.epoching.v1.MsgWrappedDelegate",
                    "value": {
                        "msg": {
                            "delegatorAddress": "bbn1pq0w7wedwvgttv4zjr99kx6n6e8ennu9xevztg",
                            "validatorAddress": "bbnvaloper167c8w87exp0nekcuyy8c657uh9xhrukpd6laxh",
                            "amount": {
                                "denom": "ubbn",
                                "amount": "100000"
                            }
                        }
                    }
                }
            ],
            "fee": {
                "amount": [
                    {
                        "amount": "7500",
                        "denom": "ubbn"
                    }
                ],
                "gas": "300000"
            },
            "memo": "",
            "encodedBody": "0a9c010a272f626162796c6f6e2e65706f6368696e672e76312e4d73675772617070656444656c656761746512710a6f0a2a62626e317071307737776564777667747476347a6a7239396b78366e366538656e6e75397865767a7467123162626e76616c6f7065723136376338773837657870306e656b637579793863363537756839786872756b7064366c6178681a0e0a047562626e1206313030303030",
            "encodedAuthInfo": "12120a0c0a047562626e12043735303010e0a712",
            "messageHash": "5e0061bd3b667089618336e0d9b563fa983eee378ecc6290d503cd3b9a83e670"
        },
        "createdAt": "2025-06-25T10:56:38.129Z",
        "extraData": {
            "currency": "bbn",
            "validatorAddress": "bbnvaloper167c8w87exp0nekcuyy8c657uh9xhrukpd6laxh",
            "stashAccountAddress": "bbn1pq0w7wedwvgttv4zjr99kx6n6e8ennu9xevztg",
            "rewardDestinationAddress": "bbn1pq0w7wedwvgttv4zjr99kx6n6e8ennu9xevztg"
        }
    }
}
  • amount — amount of tokens to bond. BABY is used for the mainnet network.
  • unsignedTransactionData — object containing the unsigned transaction. Sign the transaction and submit it to the blockchain to perform the called action:
    • messages — array of transaction messages. Each message describes the staking operation (MsgWrappedDelegate).
      • typeUrl — type URL of the message, e.g., /babylon.epoching.v1.MsgWrappedDelegate.
      • value — message payload in object format (protobuf-JSON).
        • msg.delegatorAddress — Babylon account address initiating the delegation.
        • msg.validatorAddress — validator address to receive the delegation.
        • msg.amount.denom — denomination of the staked amount (always ubbn for Babylon).
        • msg.amount.amount — amount to delegate, in ubbn (1 BABY = 1,000,000 ubbn).
    • fee — fee object:
      • amount — array with fee details (amount and denom).
      • gas — gas limit for the transaction.
    • memo — transaction memo, if set.
    • encodedBody — base64-encoded transaction body (protobuf-encoded).
    • encodedAuthInfo — base64-encoded auth info for the transaction.
    • messageHash — hash of the transaction message, to be signed.
  • createdAt — timestamp of the transaction in ISO 8601 format.
  • extraData — additional transaction details:
    • currency — native token of the network (always bbn for Babylon).
    • validatorAddress — validator receiving the delegation.
    • stashAccountAddress — account address performing the staking operation.
    • rewardDestinationAddress — account address to receive staking rewards.

2. Sign and Send Transaction

Use unsignedTransactionData to sign the transaction using the BABY-specific signing logic.

To broadcast the signed transaction to the BABY network, send a POST request to /api/v1/unified/transaction/broadcast.

Example request:

curl --request POST \
     --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <token>' \
     --data '{
    "chain": "babylon",
    "network": "babylon-testnet",
    "stakerAddress": "bbn18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp",
    "amount": 0.1,
    "signedTransaction": "0a9e010a96010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c6567617465126f0a2a7365693138667a67767a79336830713634367771326e777a34327a72743578737279757366386a6d6d70123173656976616c6f70657231716d70786c7377776b3432777961363774377a736161776633767572303363756576737330681a0e0a04757365691206313030303030120361626312660a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103c0caf89df9997994f61207d69c755060aeadf9cbf1ba3ea3fa9117bdb304414e12040a020801180612120a0c0a047573656912043438353110e4eb0b1a4012ce8717390c205ea7fc800c1d0aeacc260d558906f2825756cdef24a13daaae57256b6a8b1085ae8af77f8c9a59a83933b9f5a456e5d563f9048ab1bb691036"
}'
  • chain — blockchain network, always set to babylon for Babylon-related requests.
  • network — environment in which the transaction is processed (babylon-mainnet or babylon-testnet).
  • stakerAddress — Babylon account address initiating the bonding transaction.
  • amount — amount of tokens bonded.
  • signedTransaction — signed transaction in base64-encoded or hex-encoded format, containing all transaction details and signatures required for broadcasting.

Example response:

{
    "error": null,
    "result": {
        "status": "success",
        "extraData": {
            "blockId": 1315536,
            "fee": 0.0075,
            "gas": {
                "used": 84287,
                "wanted": 300000
            },
            "transactionHash": "01BD720B07AC1E5AE0A55362DCAEC2BEDD125F31AD91A08EA74DAC23E03FB896"
        }
    }
}
  • status — transaction status.
  • extraData — additional transaction details:
    • blockId — unique block identifier.
    • fee — transaction fee paid (in BBN).
    • gas — gas usage details:
      • used — actual gas used by the transaction.
      • wanted — gas limit set for the transaction.
    • transactionHash — transaction hash (hexadecimal).

Unstaking Flow

1. Create Unstaking Request

Send a POST request to /api/v1/unified/staking/unstake.

Example request:

curl --request POST \
     --url https://api-test.p2p.org/api/v1/unified/staking/unstake \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <token>' \
     --data '{
    "chain": "babylon",
    "network": "babylon-testnet",
    "stakerAddress": "bbn18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp",
    "extra": {
        "amount": 0.1
    }
}'
  • chain — blockchain network, always set to babylon for Babylon-related requests.
  • network — environment in which the transaction is processed (babylon-mainnet or babylon-testnet).
  • stakerAddress — Babylon account address initiating the bonding transaction.
  • extra — additional request parameters:
    • amount — amount of tokens to bond. BABY is used for the mainnet network.

Example response:

{
  "result": {
    "amount": 3,
    "currency": "bbn",
    "validatorAddress": "bbnvaloper1ytenacqmp6xzwwfa42shg3ch9vhzk6z57dtgyt",
    "stashAccountAddress": "bbn1pxrvq47p3rsls02ln9qqpryl5w5pnr76naesm5",
    "rewardDestinationAddress": "bbn1pxrvq47p3rsls02ln9qqpryl5w5pnr76naesm5",
    "transactionData": {
      "messages": "...",
      "fee": "...",
      "memo": "...",
      "encodedBody": "...",
      "encodedAuthInfo": "...",
      "messageHash": "..."
    },
    "createdAt": "2024-12-24T14:49:23.998Z"
  }
}
  • amount — amount of tokens to unbond. BABY is used for the mainnet network.
  • currency — token symbol (always bbn for Babylon).
  • validatorAddress — validator from which tokens are being unbonded.
  • stashAccountAddress — account address initiating the unstake operation.
  • rewardDestinationAddress — address receiving staking rewards.
  • transactionData — object with unsigned transaction details:
    • messages — array of messages to be included in the transaction.
    • fee — fee object for the transaction.
    • memo — memo field, if any.
    • encodedBody — base64-encoded transaction body.
    • encodedAuthInfo — base64-encoded auth info.
    • messageHash — transaction message hash to be signed.
  • createdAt — timestamp of the transaction in ISO 8601 format.

2. Sign and Send Transaction

Use unsignedTransactionData to sign and send the transaction following the BABY-specific signing logic.

What's Next?