Sign and Broadcast Transaction
To complete staking or withdrawal operations on Babylon, sign the unsigned transaction provided by the Staking API and broadcast it to the network.
1. Prepare the transaction
Retrieve a transaction hex from the relevant API endpoint, e.g., staking/stake, staking/unstake, staking/withdrawal.
2. Sign the transaction
Use the P2P Signer SDK to sign the unsigned data following protocol specific configuration.
3. Send the transaction
Broadcast the transaction to the network by sending a POST request to /api/v1/babylon-btc/{network}/transaction/send.
Example request (for sigNet network):
curl --request POST \
--url https://api.p2p.org/api/v1/babylon-btc/signet/transaction/send \
--header 'accept: application/json' \
--header 'authorization: Bearer <token>' \
--header 'content-type: application/json' \
--data '
{
"tranasctionHex": "70736274ff0100e402000000014f0d8e70d376cda7200bc900803d35dab2658fad9ce15454326b642523660ae90200000000fdffffff04b80b000000000000225120df0ec02350705a695b526f5c7662f33d8f8256cbd80cf8cda6d7c46d7d1578d00000000000000000496a4762626434002be65fdd561fee421c4f4564b02e4de31f74836b9b8cd1bbbf9d9c544733614e4bf609ba8977d3fbf4dee7f9d993c41f2fa584ccd27b3e4bf04a5376267e13c000c8025d0000000000002251208e68d4dba630100ab10ca873c961076b819f0c85b10be7aae6f493b60ed4ec48102700000000000000000000000001012bc5690000000000002251208e68d4dba630100ab10ca873c961076b819f0c85b10be7aae6f493b60ed4ec480000000000",
"maxFee": 1000000
}`transactionHex— signed transaction in the hexadecimal format which needs to be broadcasted to the network.maxFee— maximum fee in SATOSHI that can be charged for processing the transaction (1 BTC = 10⁸ SATOSHI).
Example response:
{
"error": null,
"result": {
"transactionHash": "70736274ff0100e402000000014f0d8e70d376cda7200bc900803d35dab2658fad9ce15454326b642523660ae90200000000fdffffff04b80b000000000000225120df0ec02350705a695b526f5c7662f33d8f8256cbd80cf8cda6d7c46d7d1578d00000000000000000496a4762626434002be65fdd561fee421c4f4564b02e4de31f74836b9b8cd1bbbf9d9c544733614e4bf609ba8977d3fbf4dee7f9d993c41f2fa584ccd27b3e4bf04a5376267e13c000c8025d0000000000002251208e68d4dba630100ab10ca873c961076b819f0c85b10be7aae6f493b60ed4ec48102700000000000000000000000001012bc5690000000000002251208e68d4dba630100ab10ca873c961076b819f0c85b10be7aae6f493b60ed4ec480000000000"
}
}transactionHash— hash of the transaction.
What's next?
- Getting Started
- Withdrawal
- Staking API reference
Updated 10 days ago