Getting Started
Staking in the Solana network using the Staking API consists of several main steps:
- Create a staking request.
- Sign and send the transaction to the network.
Get an authentication token to start using Staking API.
Request examples are provided using cURL.
1. Create staking request
Send a POST request to /api/v1/solana/{network}/staking/stake.
Example request (for testnet network):
curl --request POST \
--url https://api-test.p2p.org/api/v1/solana/testnet/staking/stake \
--header 'accept: application/json' \
--header 'authorization: Bearer <token>' \
--header 'content-type: application/json' \
--data '
{
"feePayer": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf",
"fromPublicKey": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf",
"amount": "1002282880",
"stakeAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf",
"withdrawAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf"
}'feePayer— account address that will pay the fee for the transaction.fromPublicKey— account address from which the staking account will be created.amount— amount of tokens to stake in lamports (1 SOl = 10⁹ lamports). The minimum amount is1002282880.stakeAuthority— account address that can perform staking operations with the staking account. If not specified, rights will be taken from thefromPublicKeyparameter.withdrawAuthority— account address that can perform withdrawal operations with the staking account. If not specified, rights will be taken from thefromPublicKeyparameter.
Example response:
{
"result": {
"feePayer": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf",
"fromPublicKey": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf",
"stakeAccount": "6ZuLUCwVTvuQJrN1HrpoHJheQUw9Zk8CtiD3CEpHiA9E",
"stakeAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf",
"withdrawAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf",
"amount": "1002282880",
"unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f",
"createdAt": "2023-08-15T15:07:54.795Z"
}
}feePayer— account address that will pay the fee for the transaction.fromPublicKey— account address from which the staking account will be created.stakeAccount— account address that stores tokens for staking.stakeAuthority— account address that can perform staking operations with the staking account.withdrawAuthority— account address that can perform withdrawal operations with the staking account.amount— amount of tokens to stake in lamports (1 SOL = 10⁹ lamports). The minimum amount is1002282880.unsignedTransaction— unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action.createdAt— timestamp of the transaction in the ISO 8601 format.
The transaction exists for one minute.
2. Sign and send transaction
Use unsignedTransaction to sign and send the signed transaction to the Solana network.
To check the transaction status, send a GET request to /api/v1/solana/{network}/account/staking.
Example request (for testnet network):
curl --request GET \
--url https://api-test.p2p.org/api/v1/solana/testnet/account/staking?stakeAuthorities=7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf&withdrawAuthorities=7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf \
--header 'accept: application/json' \
--header 'authorization: Bearer <token>' \
--header 'content-type: application/json'stakeAuthorities— list of account addresses that can perform staking operations with staking accounts.stakeAccounts— list of staking account addresses.withdrawAuthorities— list of account addresses that can perform withdrawal operations with the staking accounts.status— staking account status:active,inactive,activating,deactivating.
Example response:
{
"result": {
"accounts": [
"amount": 2282881,
"stakeAccount": "1298uXQBW2azVA33UonLu2RoouDWkNqsV1rMUrQAy1SN",
"withdrawAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf",
"stakeAuthority": "AaMC5y1RofbY3unyrahRzyCzsesp7rfGuaGegbAg1Hxb",
"voteAccount": "FKsC411dik9ktS6xPADxs4Fk2SCENvAiuccQHLAPndvk",
"status": "active"
]
}
}-
accounts— list of stake accounts.amount— amount of tokens to stake in lamports (1 SOl = 10⁹ lamports).stakeAccount— account address that stores tokens for staking.stakeAuthority— account address that can perform staking operations with the staking account.withdrawAuthority— account address that can perform withdrawal operations with the staking account.voteAccount— vote account address.status— stake account status:active,inactive,activating,deactivating.
What's next?
- Sign and Send Transaction
- Withdrawal
- Staking API reference
Updated 12 days ago