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 Supported section.

📘

Key BABY-specific details

  • chain — always set to babylon for BABY-related requests.
  • network — environment in which the transaction is processed: babylon-testnet or babylon-mainnet.
  • amount — amount of tokens in BBN.
  • stashAccountAddress — Babylon account address initiating the staking, unstaking or withdrawal transactions.
  • validatorAddress — validator address to which tokens are delegated.
  • rewardDestinationAddress — account address receiving the staking rewards; the default value is stashAccountAddress.

Staking Flow

1. Create Staking 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 BABY-related requests.
  • network — environment in which the transaction is processed: babylon-mainnet or babylon-testnet.
  • stakerAddress — Babylon account address initiating the staking transaction.
  • amount — amount of tokens to stake in BBN, BABY native staking token.

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 stake in BBN.
  • unsignedTransactionData — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction.
    • messages — transaction messages for each staking operation.
      • typeUrl — Babylon network operation type, e.g., /babylon.epoching.v1.MsgWrappedDelegate.
      • value — message payload, encoded in the hexadecimal format.
        • msg.delegatorAddress — BABY account address initiating the delegation.
        • msg.validatorAddress — validator address receiving the delegation.
        • msg.amount.amount — amount of tokens to stake.
        • msg.amount.denom — currency of tokens, always set to ubbn (1 BBN = 10⁻⁶ uBBN).
    • fee — fee charged for processing the transaction.
      • amount — amount of tokens.
      • denom — currency of tokens: bbn, ubbn, or mbbn.
      • gas — amount of gas spent for the transaction.
    • memo — arbitrary text data to add to the transactions.
    • encodedBody — processable transaction data encoded in the hexadecimal format.
    • encodedAuthInfo — authorization data, including fee, encoded in the hexadecimal format.
    • messageHash — hash of the transaction message.
  • createdAt — timestamp of the transaction in ISO 8601 format.
  • extraData — additional transaction details:
    • currency — BBN, BABY native staking token.
    • validatorAddress — validator address to which tokens are delegated.
    • stashAccountAddress — account address initiating the staking operation.
    • rewardDestinationAddress — account address receiving the staking rewards; stashAccountAddress by default.

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 (for testnet network):

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.
  • network — environment in which the transaction is processed.
  • stakerAddress — BABY account address initiating the staking transaction.
  • amount — amount of tokens to stake in BBN.
  • signedTransaction — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network.

Example response:

{
    "error": null,
    "result": {
        "status": "success",
        "extraData": {
            "blockId": 1315536,
            "fee": 0.0075,
            "gas": {
                "used": 84287,
                "wanted": 300000
            },
            "transactionHash": "01BD720B07AC1E5AE0A55362DCAEC2BEDD125F31AD91A08EA74DAC23E03FB896"
        }
    }
}
  • status — transaction status: pending, success, or failed.
  • extraData — additional transaction details:
    • blockId — unique identifier of the block in which the transaction has been included.
    • fee — total fee in BBN charged for processing the transaction.
    • gas — computational effort required to execute the transaction, measured in gas units.
      • used — amount of gas spent for the transaction.
      • wanted — maximum gas limit available to consume for the transaction.
    • transactionHash — hash of the transaction.

Unstaking Flow

1. Create Unstaking Request

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

Example request (for testnet network):

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.
  • network — environment in which the transaction is processed.
  • stakerAddress — BABY account address initiated the staking transaction.
  • extra — additional request parameters:
    • amount — amount of tokens to unstake in BBN.

Example response:

{
  "result": {
    "amount": 3,
    "currency": "bbn",
    "validatorAddress": "bbnvaloper1ytenacqmp6xzwwfa42shg3ch9vhzk6z57dtgyt",
    "stashAccountAddress": "bbn1pxrvq47p3rsls02ln9qqpryl5w5pnr76naesm5",
    "rewardDestinationAddress": "bbn1pxrvq47p3rsls02ln9qqpryl5w5pnr76naesm5",
    "unsignedtransactionData": {
      "messages": "...",
      "fee": "...",
      "memo": "...",
      "encodedBody": "...",
      "encodedAuthInfo": "...",
      "messageHash": "..."
    },
    "createdAt": "2024-12-24T14:49:23.998Z"
  }
}
  • amount — amount of tokens to unstake in BBN.
  • currency — currency of tokens: bbn, ubbn, or mbbn.
  • validatorAddress — validator address from which tokens are delegated.
  • stashAccountAddress — staking account address keeping the staked tokens.
  • rewardDestinationAddress — rewards destination account address.
  • unsignedTransactionData — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the unstaking transaction.
    • messages — transaction messages for each staking operation.
      • typeUrl — BABY network operation type.
      • delegatorAddress — delegator address.
      • validatorAddress — validator address.
      • amount — amount of tokens to unstake.
      • denom — currency of tokens, always set to ubbn (1 BBN = 10⁻⁶ uBBN).
    • fee — fee charged for processing the transaction.
      • amount — amount of tokens.
      • denom — currency of tokens: bbn, ubbn, or mbbn.
      • gas — amount of gas spent for the transaction.
    • memo — arbitrary text data to add to the transactions.
    • encodedBody — processable transaction data encoded in the hexadecimal format.
    • encodedAuthInfo — authorization data, including fee, encoded in the hexadecimal format.
    • messageHash — hash of the transaction.
  • createdAt — timestamp of the transaction in the 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?