Sign and Broadcast Transaction

To complete any staking or withdrawal operation on TON, sign the unsigned transaction provided by the Staking API and broadcast it to the network.

1. Prepare the transaction

Retrieve an unserialized transaction data from the relevant API endpoint, e.g., single-nominator/stake, ton-whales/unstake.

2. Sign the transaction

Use the P2P Signer SDK to sign the unsigned data following protocol specific configuration.

3. Send the transaction

Broadcast the transaction to the network by sending 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"
}
'
  • signedTransactionsigned 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.
  • walletVersionversion of the smart contract used by the wallet in the TON blockchain.

Example response:

{
    "error": null,
    "result": {
        "extraData": {
            "messageHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
        }
    }
}
  • messageHash — hash of the transaction.

What's next?