TRON

Unified API + TRON Integration Workflow

In the following guide, the integration process for the tron chain is covered. TRON integration aligns with the general Unified API process but with network-specific parameters.

Get an authentication token to start using the Unified API.

Request examples are provided using cURL.

To check the integration guides for other chains, refer to the Networks Supported section.

📘

Key TRON-specific details

  • chain — always set to tron for TRON-related requests.
  • network — environment in which the transaction is processed: mainnet ortestnet-nile.
  • stakerAddress — TRON account address initiating staking, voting or withdrawal transactions.
  • amount — amount of tokens in SUN (1 TRX = 10⁶ SUN). Note that only TRX (SUN) can be staked, since USDT (TRC-20) is not natively stakeable.

Staking Flow

1. Create Freeze Request

Send a POST request to /api/v1/unified/staking/stake.

Example request (for testnet-nile network):

curl --request POST \
     --url https://api-test.p2p.org/api/v1/unified/staking/stake \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <token>' \
     --data '{
    "chain": "tron",
    "network": "testnet-nile",
    "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
    "amount": 1000000,
    "extra": {
        "resource": "BANDWIDTH"
    }
}'
  • chain — blockchain network, always set to tron for TRON-related requests.
  • network — environment in which the transaction is processed: mainnet ortestnet-nile.
  • stakerAddress — TRON account address initiating the freeze transaction.
  • amount — amount of tokens to freeze in SUN (1 TRX = 10⁶ SUN). Note that only TRX (SUN) can be staked, since USDT (TRC-20) is not natively stakeable.
  • extra — additional request parameters:
    • resource — type of resources to be used for processing the TRON transactionBANDWIDTH or ENERGY.

Example response:

{
    "error": null,
    "result": {
        "amount": 1000000,
        "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
        "createdAt": "2025-06-26T19:18:33.983Z",
        "extraData": {
            "unsignedTransactionData": {
                "visible": false,
                "txID": "5fa8e694866ba0ecfcbf4d4932552ad7f9a198fccc30b5d0b4a1564a986cec8a",
                "raw_data_hex": "0a02ed712208bed86bc0563959f54088abb9edfa325a57083612530a34747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e63655632436f6e7472616374121b0a1541da53d324a354aa5924c7117caff3ead97910a5e110c0843d70a8d6b5edfa32",
                "raw_data": {
                    "contract": [
                        {
                            "parameter": {
                                "value": {
                                    "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1",
                                    "frozen_balance": 1000000
                                },
                                "type_url": "type.googleapis.com/protocol.FreezeBalanceV2Contract"
                            },
                            "type": "FreezeBalanceV2Contract"
                        }
                    ],
                    "ref_block_bytes": "ed71",
                    "ref_block_hash": "bed86bc0563959f5",
                    "expiration": 1750965573000,
                    "timestamp": 1750965513000
                }
            }
        }
    }
}
  • amount — amount of tokens to freeze in SUN (1 TRX = 10⁶ SUN). Note that only TRX (SUN) can be staked, since USDT (TRC-20) is not natively stakeable.
  • stakeAddress — TRON account address initiating the freeze transaction.
  • createdAt — timestamp of the transaction in the ISO 8601 format.
  • extraData — additional transaction details:
    • unsignedTransactionData — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction.
      • visible — internal SDK parameter; always set to false.
      • txID — hash of the freeze transaction.
      • raw_data_hex — raw payload of the unsigned transaction in the hexadecimal format.
      • raw_data — full decoded transaction structure with all the fields and metadata:
        • contract — list of TRON contracts:
          • parameter.type_url — TRON network operation type, e.g., type.googleapis.com/protocol.FreezeBalanceV2Contract.
          • parameter.value.owner_address — TRON account address initiated the transaction in the hexadecimal format.
          • parameter.value.frozen_balance — amount of tokens to freeze in SUN (1 TRX = 10⁶ SUN).
        • ref_block_bytes, ref_block_hash — hash and references of the block in which the transaction has been included.
        • expiration — timestamp of the transaction expiration in ms since last epoch.
        • timestamp — timestamp of the transaction in ms since last epoch.

2. Sign and Send Transaction

Use unsignedTransactionData to sign the transaction using the TRON-specific signing logic.

To broadcast the signed transaction to the TRON network, send a POST request to /api/v1/unified/transaction/broadcast.

Example request (for testnet-nile network):

curl --request POST \
     --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <token>' \
     --data '{
    "chain": "tron",
    "network": "testnet-nile",
    "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
    "signedTransaction": "0x410284007427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e01f214ddb36378b5f5927b06028eccfe284d9cb736f8552e301cc09c2006998b098f84bf6386a201aa952fe298dd5f0c5fb6f03fc7b9f7efafd87b6ee321500b8e450340000600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e"
}'
  • chain — blockchain network, always set to tron.
  • network — environment in which the transaction is processed.
  • stakerAddress — TRON account address initiated the transaction.
  • signedTransaction — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network.

Example response:

{
    "error": null,
    "result": {
        "status": "PENDING",
        "extraData": {
            "transactionHash": "71e64f4fca71012b4ee5a40c90eed269875e4a796011e42f46358da68f758a34",
            "createdAt": "2025-06-26T19:25:13.712Z",
            "network": "testnet-nile",
            "senderAddress": "41da53d324a354aa5924c7117caff3ead97910a5e1",
            "block": null,
            "gas": {
                "bandwidthUsed": 0,
                "energyUsed": 0
            }
        }
    }
}
  • status — transaction status: pending, success or failed.
  • extraData — additional transaction details:
    • transactionHash — hash of the transaction.
    • createdAt — timestamp of the transaction in the ISO 8601 format.
    • network — environment in which the transaction is processed.
    • senderAddress — TRON account address in the hexadecimal format.
    • block — block number in which the transaction has been included; null if the transaction has not been confirmed yet.
    • gas — gas usage details:
      • bandwidthUsed — number of bandwidth points consumed for processing the TRON transaction.
      • energyUsed — amount of energy in ms representing the time spent during an execution of a smart contract.

3. Create Vote Request

To vote for a Super Representative after freezing TRX tokens, send a POST request to /api/v1/unified/staking/stake.

Example request (for testnet-nile network):

curl --request POST \
     --url https://api-test.p2p.org/api/v1/unified/staking/stake \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <token>' \
     --data '{
    "chain": "tron",
    "network": "testnet-nile",
    "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
    "amount": 1000000,
    "extra": {
        "voteAddress": "TH7Fe1W8CcLeqN4LGfqX1R9EpsnrJBQJji",
        "voteCount": 1
    }
}'
  • chain — blockchain network.
  • network — environment in which the transaction is processed.
  • stakerAddress — TRON account address initiating the voting transaction.
  • amount — amount of frozen tokens to use for voting in SUN (1 TRX = 10⁶ SUN).
  • extra — additional request parameters:
    • voteAddress — address of the Super Representative to vote for.
    • voteCount — number of votes.

Example response:

{
    "error": null,
    "result": {
        "amount": 1000000,
        "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
        "createdAt": "2025-06-26T19:26:54.816Z",
        "extraData": {
            "unsignedTransactionData": {
                "visible": false,
                "txID": "c07e64f57ebb6ae191404b1c693aa46f80789aceacbfd8cc17a7c85c0c8c5559",
                "raw_data_hex": "0a02ee182208eb04b8cce7cc51534090f5d7edfa325a6a080412660a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e747261637412320a1541da53d324a354aa5924c7117caff3ead97910a5e112190a1541351b95e29c2514b7b8183cbc81a8e08c68e8833b100370b0a0d4edfa32",
                "raw_data": {
                    "contract": [
                        {
                            "parameter": {
                                "value": {
                                    "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1",
                                    "votes": [
                                        {
                                            "vote_address": "41351b95e29c2514b7b8183cbc81a8e08c68e8833b",
                                            "vote_count": 3
                                        }
                                    ]
                                },
                                "type_url": "type.googleapis.com/protocol.VoteWitnessContract"
                            },
                            "type": "VoteWitnessContract"
                        }
                    ],
                    "ref_block_bytes": "ee18",
                    "ref_block_hash": "eb04b8cce7cc5153",
                    "expiration": 1750966074000,
                    "timestamp": 1750966014000
                }
            }
        }
    }
}
  • amount — amount of frozen tokens used for voting in SUN (1 TRX = 10⁶ SUN).
  • stakerAddress — TRON account address initiated the voting transaction.
  • createdAt — timestamp of the transaction in the ISO 8601 format.
  • extraData — additional transaction details:
    • unsignedTransactionData — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction.
      • visible — internal SDK parameter; always set to false.
      • txID — hash of the voting transaction.
      • raw_data_hex — raw payload of the unsigned transaction in the hexadecimal format.
      • raw_data — full decoded transaction structure with all the fields and metadata:
        • contract — list of TRON contracts:
          • parameter.type_url — TRON network operation type, e.g., type.googleapis.com/protocol.FreezeBalanceV2Contract.
          • parameter.value.owner_address — TRON account address in the hexadecimal format.
          • parameter.value.frozen_balance — amount of tokens used for voting in SUN (1 TRX = 10⁶ SUN).
        • ref_block_bytes, ref_block_hash — hash and references of the block in which the transaction has been included.
        • expiration — timestamp of the transaction expiration in ms since last epoch.
        • timestamp — timestamp of the transaction in ms since last epoch.

4. Sign and Send Transaction

Use unsignedTransactionData to sign and send the transaction following the TRON-specific signing logic.

Unstaking Flow

1. Create Unfreeze Request

Send a POST request to /api/v1/unified/staking/unstake.

Example request (for testnet-nile network):

curl --request POST \
     --url https://api-test.p2p.org/api/v1/unified/staking/unstake \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <token>' \
     --data '{
    "chain": "tron",
    "network": "testnet-nile",
    "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
    "extra": {
        "amount": 1000000,
        "resource": "BANDWIDTH"
    }
}'
  • chain — blockchain network.
  • network — environment in which the transaction is processed.
  • stakerAddress — TRON account address initiating the unfreeze transaction.
  • extra — additional request parameters:
    • amount — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN).
    • resource — type of resources used for processing the freeze transaction:BANDWIDTH or ENERGY.

Example response:

{
    "error": null,
    "result": {
        "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u",
        "createdAt": "2025-06-26T19:28:54.816Z",
        "extraData": {
            "unsignedTransactionData": {
                ... // (same transaction structure as above)
            }
        }
    }
}
  • amount — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN).
  • stakerAddress — TRON account address initiated the unfreeze transaction.
  • createdAt — timestamp of the transaction in the ISO 8601 format.
  • extraData — additional transaction details:
    • unsignedTransactionData — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction.
      • visible — internal SDK parameter; always set to false.
      • txID — hash of the unfreeze transaction.
      • raw_data_hex — raw payload of the unsigned transaction in the hexadecimal format.
      • raw_data — full decoded transaction structure with all the fields and metadata:
        • contract — list of TRON contracts:
          • parameter.type_url — TRON network operation type, e.g., type.googleapis.com/protocol.FreezeBalanceV2Contract.
          • parameter.value.owner_address — TRON account address in the hexadecimal format.
          • parameter.value.frozen_balance — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN).
        • ref_block_bytes, ref_block_hash — hash and references of the block in which the transaction has been included.
        • expiration — timestamp of the transaction expiration in ms since last epoch.
        • timestamp — timestamp of the transaction in ms since last epoch.

2. Sign and Send Transaction

Use unsignedTransactionData to sign and send the transaction following the TRON-specific signing logic.

What's Next?