Skip to main content
All CollectionsAPI
Solana Staking API
Solana Staking API
Allnodes Team avatar
Written by Allnodes Team
Updated over a week ago

The Allnodes API generates serialized unsigned transactions. To send a transaction to the network, you will need experience with Solana Web3:
https://solana-labs.github.io/solana-web3.js

In every HTTP request of the Allnodes API, you need to specify your API key via an HTTP header: Authorization: Bearer <YOUR_API_KEY>


Solana API documentation: https://docs.allnodes.com/sol/staking


How to get an API key:

  1. Register an account here: https://www.allnodes.com

  2. Go to the settings of your account: https://www.allnodes.com/settings

  3. Open the API tab.

  4. Click on the "Enable API" button.

  5. Save the "Read and Write API Key" and "Read-Only API Key" in a safe place.


How to Stake

  1. You must create a stake account and prepare your address with at least 1.1 SOL.
    If you already have a stake account, go to step 6.

  2. Send an HTTP POST request to the URL https://www.allnodes.com/api/v1/staking with the following json body:

    {
    "address": "<YOUR_ADDRESS>",
    "amount": "<SOL_AMOUNT_TO_STAKE>",
    "currencySymbol": "SOL",
    "action": "create-stake-account"
    }


    Example:

    curl --location --request POST 'https://www.allnodes.com/api/v1/staking' \
    --header 'Authorization: Bearer <YOUR_API_KEY>' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "address": "<YOUR_ADDRESS>",
    "amount": "<SOL_AMOUNT_TO_STAKE>",
    "currencySymbol": "SOL",
    "action": "create-stake-account"
    }'


    If you specify amount = 0, the account will be generated with the minimum amount of SOL necessary to create an account in the Solana network (~0.003 SOL). In case you specify any amount - it will go to the balance of the stake account at its creation and can be used to stake later.


    The response to your request contains:

    • stakeAccountSecretKey - secret key required to sign account creation transaction. Keep it in a safe place.

    • stakeAccountPublicKey - keep your public key in a safe place. It will be required for account operations.

    • serializedTransaction - sign and send this transaction to the network using Solana Web3.js

  3. You have successfully created a staking account. But the status of the stake is "inactive". So now you need to delegate your stake to the Allnodes validator to activate it.

  4. Send an HTTP POST request to the URL https://www.allnodes.com/api/v1/staking with the following json body:

    {
    "address": "<YOUR_ADDRESS>",
    "stakeAccountPublicKey": "<YOU_STAKE_ACCOUNT_PUBLIC_KEY>",
    "currencySymbol": "SOL",
    "action": "stake"
    }

    Example:

    curl --location --request POST 'https://www.allnodes.com/api/v1/staking' \
    --header 'Authorization: Bearer <YOUR_API_KEY>' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "address": "<YOUR_ADDRESS>",
    "stakeAccountPublicKey": "<YOU_STAKE_ACCOUNT_PUBLIC_KEY>",
    "currencySymbol": "SOL",
    "action": "stake"
    }'

    The response to your request contains:
    serializedTransaction - sign and send this transaction to the network using Solana Web3.js

  5. You successfully delegated your staked coins to Allnodes, and your stake is now "activating". It will then become "active".


How to Withdraw Your Stake

  1. You will first need to deactivate your stake account and wait for the unbonding period to finish (usually, it's about 2 days).
    If you have already deactivated your stake account, go to step 4.

  2. To withdraw your stake, send an HTTP POST request to the URL https://www.allnodes.com/api/v1/staking with the following json body:

    {
    "address": "<YOUR_ADDRESS>",
    "stakeAccountPublicKey": "<YOU_STAKE_ACCOUNT_PUBLIC_KEY>",
    "currencySymbol": "SOL",
    "action": "unbond-stake"
    }

    Example:

    curl --location --request POST 'https://www.allnodes.com/api/v1/staking' \
    --header 'Authorization: Bearer <YOUR_API_KEY>' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "address": "<YOUR_ADDRESS>",
    "stakeAccountPublicKey": "<YOU_STAKE_ACCOUNT_PUBLIC_KEY>",
    "currencySymbol": "SOL",
    "action": "unbond-stake"
    }'

    The response to your request contains:

    serializedTransaction - sign and send this transaction to the network using Solana Web3.js

  3. You successfully deactivated your stake account! Now you need to wait 2 days before withdrawing your staked coins.

  4. Send an HTTP POST request to the URL https://www.allnodes.com/api/v1/staking with the following JSON body:

    {
    "address": "<YOUR_ADDRESS>",
    "stakeAccountPublicKey": "<YOU_STAKE_ACCOUNT_PUBLIC_KEY>",
    "amount": "<SOL_AMOUNT_TO_WITHDRAW>",
    "currencySymbol": "SOL",
    "action": "withdraw-stake"
    }

    Example:

    curl --location --request POST 'https://www.allnodes.com/api/v1/staking' \
    --header 'Authorization: Bearer <YOUR_API_KEY>' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "address": "<YOUR_ADDRESS>",
    "stakeAccountPublicKey": "<YOU_STAKE_ACCOUNT_PUBLIC_KEY>",
    "amount": "<SOL_AMOUNT_TO_WITHDRAW>",
    "currencySymbol": "SOL",
    "action": "withdraw-stake"
    }'

    The response to your request contains:

    serializedTransaction - sign and send this transaction to the network using Solana Web3.

  5. You have successfully withdrawn your staked coins!


How to Get a List of Your Stake Accounts

  1. Send an HTTP POST request to the URL https://www.allnodes.com/api/v1/staking with the following json body:

    {
    "address": "<YOUR_ADDRESS>",
    "currencySymbol": "SOL",
    "action": "get-stake-accounts"
    }


    Example:

    curl --location --request POST 'https://www.allnodes.com/api/v1/staking' \
    --header 'Authorization: Bearer <YOUR_API_KEY>' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "address": "<YOUR_ADDRESS>",
    "currencySymbol": "SOL",
    "action": "get-stake-accounts"
    }'

    The response to your request contains:

    • publicKey - the public key of your staking account;

    • rentEpoch - the era from which the tokens were staked;

    • lamports - the balance of the account in lamports;

    • stake - the total amount of user stake;

    • validatorPublicKey - validators public key assigned with this stake;

    • active - part of the stake that is active now;

    • inactive - part of the stake that is inactive now;

    • state - current status of stake, it can be 'active' | 'inactive' | 'activating' | 'deactivating';

Did this answer your question?