TON
Introduction
The TON integration aligns with the general Getting Started process, with network-specific parameters highlighted below. parameters and network-specific logic.
Key TON-Specific Details
chain
— always set to ton_whales for TON-related requests.network
— specifies the environment (testnet
ormainnet
).stakerAddress
— represents the account address used for staking, unstaking, and withdrawal operations.
Unsigned Transactions — use TON-specific signing logic for unsignedTransactionData
. For details, refer to Transaction Signing.
Quick Steps for TON
Staking Flow
- Create a Stake Transaction: Refer to Create Stake Transaction to send the transaction details.
- Sign and Broadcast Transaction: Use TON-specific signing logic as outlined in Sign and Broadcast transaction.
Unstaking Flow
- Create Unstake Transaction: Refer to Create an Unstake Transaction to send the transaction details.
- Sign and Broadcast Transaction: Use TON-specific signing logic as outlined in Sign and Broadcast transaction.
- Create Withdrawal Transaction: Refer to the Create Withdrawal Transaction section for request structure.
- Sign and Broadcast Transaction: Use TON-specific signing logic as outlined in Sign and Broadcast transaction.
Unified API + TON Integration Workflow
Staking Flow
Step 1. Create Staking Transaction
Send a POST request to https://api-test.p2p.org/api/v1/unified/staking/stake.
Example request:
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": "testnet",
"stakerAddress": "0QDZncytCDTPJylG1POFhqzeCLDFZNKhJ2v73lcsBNjQHMZx",
"amount": "20000000000"
}'
Example response:
{
"error": null,
"result": {
"unsignedTransaction": "b5ee9c7241010101003800006b000010000000000000000001000000039fedeab7a2b56b38f19f60b5b9f70b2f1ba2d89b9c5a756036c7cfad73571fb281887735940193456f7e",
"walletVersion": "V4",
"stakerAddress": "0QDZncytCDTPJylG1POFhqzeCLDFZNKhJ2v73lcsBNjQHMZx",
"publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6",
"amount": 2
}
}
Step 2. Sign and Broadcast transaction
Use unsignedTransactionData
to sign the transaction.
Send a POST request to https://api-test.p2p.org/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": "testnet",
"stakerAddress": "0QDZncytCDTPJylG1POFhqzeCLDFZNKhJ2v73lcsBNjQHMZx",
"signedTransaction": "b5ee9c7241010101003800006b000010000000000000000001000000039fedeab7a2b56b38f19f60b5b9f70b2f1ba2d89b9c5a756036c7cfad73571fb281887735940193456f7e"
}'
Example response:
{
"error": null,
"result": {
"address": "0QDZncytCDTPJylG1POFhqzeCLDFZNKhJ2v73lcsBNjQHMZx",
"lt": "27726830000001",
"prevTransactionHash": "6210303f3cfb630c349b3859d9e367a65a6772938c681774e2a315aa95c80224",
"prevTransactionLt": "1234567890abcdef",
"now": 1730905768,
"outMessagesCount": 1,
"oldStatus": "active",
"endStatus": "active",
"transactionHash": "2829e4bb8a7b8084040c731a07523d680ce30fecef12f8eec1e409f3c6077a5e"
},
}
Unstaking Flow
Step 1: Create an Unstake Transaction
Send a POST request to https://api-test.p2p.org/api/v1/unified/staking/unstake.
Example request:
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": "ton_whales",
"network": "testnet",
"stakerAddress": "0QDZncytCDTPJylG1POFhqzeCLDFZNKhJ2v73lcsBNjQHMZx",
"extra": {
"amount": "20000000000",
"publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6"
}
}'
Example response:
{
"error": null,
"result": {
"unsignedTransaction": "b5ee9c7241010101003800006b000010000000000000000001000000039fedeab7a2b56b38f19f60b5b9f70b2f1ba2d89b9c5a756036c7cfad73571fb281887735940193456f7e",
"publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6",
"amount": "2"
}
}
Step 2. Sign and Broadcast Unstake Transaction
Sign and broadcast the transaction as outlined above.
What's Next?
Updated about 12 hours ago