Getting Started

To start staking on the Bitcoin network using the Staking API:

  1. Create a stake transaction.
  2. Sign and send the transaction to the network.

Get an authentication token to start using Staking API.

Request examples are provided using cURL.

🚧

Please note

As the Babylon protocol for the mainnet is in the first launching phase, the staking flow is currently limited to only initiating the staking process by submitting time-lock transactions to the Bitcoin blockchain. No direct rewards is considered until the next launching phase.

However, early unbonding is possible, see Withdrawal .

1. Create Stake Transaction

Initiate the staking process by sending a POST request to /api/v1/babylon-btc/{network}/staking/stake.

Example request (for sigNet network):

curl --request POST \
     --url https://api-test.p2p.org/api/v1/babylon-btc/signet/staking/stake \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <token>' \
     --header 'content-type: application/json'
     --data '
     {
     "stakerPublicKey": "02be65fdd561fee421c4f4564b02e4de31f74836b9b8cd1bbbf9d9c544733614e4",
     "stakerAddress": "tb1p3e5dfkaxxqgq4vgv4peujcg8dwqe7ry9ky9702hx7jfmvrk5a3yq4q5ua9",
     "stakeAmount": 30000,
     "stakingDuration": 150
     }'
  • stakerPublicKey — staker public key.
  • stakerAddress — staker taproot address.
  • stakeAmount — amount to stake in SATOSHI (1 BTC = 10⁸ SATOSHI). Note that the maximum amount for staking is limited to 1000 BTC.
  • stakingDuration — time-lock period for staking in Bitcoin blocks. The maximum is 64 000 Bitcoin blocks, which is approximately 15 months. The time lock comes into effect after the Bitcoin transaction has been included in a mined block.

Example response:

{
  "error": null,
  "result": {
    "stakerPublicKey": "02be65fdd561fee421c4f4564b02e4de31f74836b9b8cd1bbbf9d9c544733614e4",
    "stakerAddress": "tb1p3e5dfkaxxqgq4vgv4peujcg8dwqe7ry9ky9702hx7jfmvrk5a3yq4q5ua9",
    "stakingAmount": 1000000,
    "stakingDuration": 100,
    "finallyProviderPublicKey": "02be65fdd561fee421c4f4564b02e4de31f74836b9b8cd1bbbf9d9c544733614e4",
    "stakeTransactionHex": "0,000009998373764507203",
    "fee": 1000
	}
}
  • stakerPublicKey — staker public key.
  • stakerAddress — staker taproot address.
  • stakingAmount — amount to stake in SATOSHI (1 BTC = 10⁸ SATOSHI).
  • stakingDuration — time-lock period for staking in Bitcoin blocks.
  • finallyProviderPublicKey — finality provider public key produced by the Schnorr signature algorithm.
  • stakeTransactionHexunsigned transaction in the hexadecimal format. Sign the stake transaction and submit it to the Bitcoin blockchain to perform the called action.
  • fee — total fee in SATOSHI charged for processing the transaction.

2. Sign and Broadcast Transaction

Use stakeTransactionHex from the previous step to sign and send the signed transaction to the Bitcoin chain.

To check the transaction status, send a GET request to /api/v1/babylon-btc/{network}/transaction/get-by-tx-hash/{txHash}.

Example request (for sigNet network):

curl --request GET \
     --url https://api-test.p2p.org/api/v1/babylon-btc/signet/transaction/get-by-tx-hash/{txHash} \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <token>' \
     --header 'content-type: application/json'

Example response:

{
  "error": null,
  "result": {
    "stakerPublicKey": "02be65fdd561fee421c4f4564b02e4de31f74836b9b8cd1bbbf9d9c544733614e4",
    "stakeTransactionHash": "",
    "unstakeTransactionHex": "70736274ff0100e402000000014f0d8e70d376cda7200bc900803d35dab2658fad9ce15454326b642523660ae90200000000fdffffff04b80b000000000000225120df0ec02350705a695b526f5c7662f33d8f8256cbd80cf8cda6d7c46d7d1578d00000000000000000496a4762626434002be65fdd561fee421c4f4564b02e4de31f74836b9b8cd1bbbf9d9c544733614e4bf609ba8977d3fbf4dee7f9d993c41f2fa584ccd27b3e4bf04a5376267e13c000c8025d0000000000002251208e68d4dba630100ab10ca873c961076b819f0c85b10be7aae6f493b60ed4ec48102700000000000000000000000001012bc5690000000000002251208e68d4dba630100ab10ca873c961076b819f0c85b10be7aae6f493b60ed4ec480000000000"
  }
}
  • stakerPublicKey — staker public keys.
  • stakeTransactionHash — hash of the stake transaction.
  • unstakeTrahsactionHex — unsigned transaction in the hexadecimal format required for unstaking, see Withdrawal.

What's Next?