Sign and Broadcast Transaction
To sign and broadcast a transaction to the TON network:
-
Initialize the service by installing dependencies from this repository.
-
In the ton-sign.ts file, specify the staker account's seed phrase and prepare unsigned transactions in Base64 encrypted format.
-
Sign the transaction using the code.
-
Finally, send the signed transaction to the TON network by making a POST request to /api/v1/ton/{network}/transactions/broadcast.
Example request (for the testnet
network):
curl --request POST \
--url https://api.p2p.org/api/v1/ton/testnet/transactions/broadcast \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"walletVersion": "V4",
"unsignedTransaction": "te6ccgEBAQEABgAACCiAmCM=",
"signature": "te6ccgEBAQEABgAACCiAmCM=",
"publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6"
}
'
signedTransaction
— signed transactionin the hexadecimal format which needs to be broadcasted to the network.signature
— external message signature, which has to be signed with the private key.publicKey
— public key of the nominator for the TON network.walletVersion
— version of the smart contract used by the wallet in the TON blockchain.
Example response:
{
"error": null,
"result": {
"transactionHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
}
}
transactionHash
— hash of the transaction.
What's Next?
- Getting Started.
- Withdrawal.
- Staking API reference.
Updated 1 day ago