Sign and Broadcast Transaction
To complete any staking or withdrawal operation on Babylon Genesis, sign the unsigned transaction provided by the Staking API and broadcast it to the network.
1. Prepare the transaction
Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., staking/stake, staking/unstake, staking/claim-rewards.
2. Sign the transaction
Use the P2P Signer SDK to sign the unsigned data following protocol specific configuration.
3. Send the transaction
Send a POST request to /api/v1/babylon/{network}/transaction/send.
Example request (for babylon-testnet network):
curl --request POST \
--url https://api-test.p2p.org/api/v1/babylon/babylon-testnet/transaction/send \
--header 'accept: application/json' \
--header 'authorization: Bearer <token>' \
--header 'content-type: application/json' \
--data '
{
"signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef"
}'signedTransaction— signed transaction in the hexadecimal format which needs to be broadcasted to the network.
Example response:
{
"error": null,
"result": {
"status": "success",
"blockId": 18575267,
"fee": 0.005952,
"gas": {
"used": 202947,
"wanted": 238047
},
"transactionHash": "EDDA3AE81ACBF56CB1F154F4957779C04F10B6F4C23B13597EFFC61FE05A02D2"
}
}status— transaction status:success,failed.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 that the transaction initiator was willing to consume for the transaction.
transactionHash— hash of the transaction.
What's next?
- Staking API reference
- Unified API
- Unified API Reference
Updated 1 day ago