TON

Unified API + TON Integration Workflow

In the following guide, the integration process for the ton_whales chain and mainnet network is covered. The TON 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 section.

📘

Key TON-specific details

  • chain — always set to ton_whales for TON-related requests.
  • network — environment in which the transaction is processed (mainnet or testnet).
  • stakerAddress — account address initiating staking, unstaking, or withdrawal transactions.
  • amount — amount of tokens in nanoTONs (1 TON = 10⁹ nanoTONs).
  • walletVersionversion of the smart contract used by the wallet for staking operations.
  • publicKey — public key of the nominator for the TON network.

Staking Flow

1. Create Staking Request

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

Example request (for mainnet 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": "ton_whales",
    "network": "mainnet",
    "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE",
    "extra": {
        "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d",
        "amount": "5000000000",
        "walletVersion": "V3R1"
    }
}'
  • chain — blockchain network, always set to ton_whales for TON-related requests.

  • network — environment in which the transaction is processed.

  • stakerAddress — staking account address receiving the staked tokens.

  • publicKey — public key of the nominator for the TON network.

  • amount — amount of tokens to stake in nanoTONs (1 TON = 10⁹ nanoTONs).

  • walletVersionversion of the smart contract used by the wallet in the TON blockchain.

Example response:

{
    "error": null,
    "result": {
        "amount": "5000000000",
        "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE",
        "unsignedTransactionData": "b5ee9c7241010201005c00011a29a9a3176761922b0000000f0301009462001b0eecbed3c3c21725606281a98dfb0152db86a09eb434df3d75fd862d8466e723b9aca00000000000000000000000000000da803efd00000193d519d3184773594005012a05f200a7846cb2",
        "extraData": {
            "seqno": 15,
            "walletVersion": "V3R1",
            "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d",
            "poolAddress": "kQA2Hdl9p4eELkrAxQNTG_YCpbcNQT1oab566_sMWwjNztst"
        }
    }
}
  • amount — amount of tokens to stake in nanoTONs (1 TON = 10⁹ nanoTONs).
  • stakerAddress — staking account address receiving the staked tokens.
  • unsignedTransactionData — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action.
  • extraData — additional transaction details:
    • seqnosequence number of the message.
    • walletVersionversion of the smart contract used by the wallet in the TON blockchain.
    • publicKey — public key of the nominator for the TON network.
    • poolAddress — TON Whales pool address.

2. Sign and Send Transaction

Use unsignedTransactionData to sign the transaction.

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

Example request:

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": "ton_whales",
    "network": "mainnet",
    "signedTransaction": "710f0456d675c0715bcdcbce5ab4fc5ad8e00cccaa3bd40fe59329cfe33c7089901bffa9c412bcd502c9f751f15de93abb297599c0dadb4f247eaeea72a2a003",
    "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE",
    "extra": {
        "unsignedTransaction": "b5ee9c7241010201005a00011c29a9a317ffffffff00000000000301008d62001b0eecbed3c3c21725606281a98dfb0152db86a09eb434df3d75fd862d8466e7280d09dc3000000000000000000000000000007bcd1fef00000193e11e3d975012a05f2008b7558aef",
        "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d",
        "walletVersion": "V3R1"
    }
}'
  • chain — blockchain network.
  • network — environment in which the transaction is processed.
  • 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.
  • stakerAddress — staking account address receiving the staked tokens.
  • extraData — additional transaction details:
    • unsignedTransaction — unsigned transaction in Base64 encrypted format.
    • publicKey — public key of the nominator for the TON network.
    • walletVersionversion of the smart contract used by the wallet in the TON blockchain.

Example response:

{
    "error": null,
    "result": {
        "extraData": {}
    }
}

Unstaking Flow

1. Create Withdrawal Request

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

Example request:

curl --request POST \
     --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <token>' \
     --data '{
    "chain": "ton_whales",
    "network": "mainnet",
    "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE",
    "extra": {
        "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d",
        "amount": "5000000000",
        "walletVersion": "V3R1"
    }
}'
  • chain — blockchain network.

  • network — environment in which the transaction is processed.

  • stakerAddress — staking account address initiating the withdrawal transaction.

  • publicKey — public key of the nominator for the TON network.

  • amount — amount of tokens to withdraw in nanoTONs (1 TON = 10⁹ nanoTONs).

  • walletVersionversion of the smart contract used by the wallet in the TON blockchain.

Example response:

{
    "error": null,
    "result": {
        "amount": "5000000000",
        "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE",
        "unsignedTransactionData": "b5ee9c7241010201005c00011a29a9a3176761922b0000000f0301009462001b0eecbed3c3c21725606281a98dfb0152db86a09eb434df3d75fd862d8466e723b9aca00000000000000000000000000000da803efd00000193d519d3184773594005012a05f200a7846cb2",
        "extraData": {
            "seqno": 15,
            "walletVersion": "V3R1",
            "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d",
            "poolAddress": "kQA2Hdl9p4eELkrAxQNTG_YCpbcNQT1oab566_sMWwjNztst"
        }
    }
}
  • amount — amount of tokens to withdraw in nanoTONs (1 TON = 10⁹ nanoTONs).
  • stakerAddress — account address initiating the withdrawal transaction.
  • unsignedTransactionData — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action.
  • extraData — additional transaction details:
    • seqnosequence number of the message.
    • walletVersionversion of the smart contract used by the wallet in the TON blockchain.
    • publicKey — public key of the nominator for the TON network.
    • poolAddress — TON Whales pool address.

2. Sign and Send Transaction

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

What's Next?