All Collections
API
TRON Staking API
TRON 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 TronWeb: https://github.com/tronprotocol/tronweb

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



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 freeze at least 1 TRX.
    If you have already freezed coins, go to step 3.

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

    {
    "currencySymbol": "TRX",
    "action": "freeze"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_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 '{
    "currencySymbol": "TRX",
    "action": "freeze"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_STAKE>"
    }'

    The response to your request contains:

    • txID – transaction ID.

    • raw_data_hex – data of unsigned transaction in hexadecimal format.

    • raw_data - data of unsigned transaction in human friendly format.

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

    {
    "currencySymbol": "TRX",
    "action": "delegate"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_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 '{
    "currencySymbol": "TRX",
    "action": "delegate"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_STAKE>"
    }'

    The response to your request contains:

    • txID – transaction ID.

    • raw_data_hex – data of unsigned transaction in hexadecimal format.

    • raw_data - data of unsigned transaction in human friendly format.

  4. You have successfully delegated your staked coins to Allnodes


How to Withdraw Your Stake

  1. You will first need to unfreeze your stake account and wait for the lockup period to finish (usually, it's about 3 days).

  2. To undelegate your stake, Send a HTTP POST request to the URL https://www.allnodes.com/api/v1/staking with the following JSON body:

    {
    "currencySymbol": "TRX",
    "action": "delegate"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_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 '{
    "currencySymbol": "TRX",
    "action": "undelegate"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_WITHDRAW>"
    }'

    The response to your request contains:

    • txID – transaction ID.

    • raw_data_hex – data of unsigned transaction in hexadecimal format.

    • raw_data - data of unsigned transaction in human friendly format.

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

    {
    "currencySymbol": "TRX",
    "action": "unfreeze"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_WITHDRAW>"
    }


    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 '{
    "currencySymbol": "TRX",
    "action": "unfreeze"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_WITHDRAW>"
    }'

    The response to your request contains:

    • txID – transaction ID.

    • raw_data_hex – data of unsigned transaction in hexadecimal format.

    • raw_data - data of unsigned transaction in human friendly format.

  4. You have successfully withdrawn your staked coins!


How to claim rewards

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

    {
    "currencySymbol": "TRX",
    "action": "undelegate"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_WITHDRAW>"
    }


    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 '{
    "currencySymbol": "TRX",
    "action": "claim"
    "address": "<YOUR_ADDRESS>",
    "amount": "<AMOUNT_TO_WITHDRAW>"
    }'

    The response to your request contains:

    • txID – transaction ID.

    • raw_data_hex – data of unsigned transaction in hexadecimal format.

    • raw_data - data of unsigned transaction in human friendly format.

  2. You have successfully withdrawn your rewards!

Did this answer your question?