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

  1. Initialize the service by installing dependencies from this repository.

  2. In the ton-sign.ts file, specify the staker account's seed phrase and prepare unsigned transactions in Base64 encrypted format.

2. Sign and broadcast the transaction

  1. Sign the transaction using the code from the repository.

  2. 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"
    }
    '
    • 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": {
        "transactionHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
      }
    }
    • transactionHash — hash of the transaction.

What's next?