Sign and Broadcast Transaction

In the Unified API, transaction signing logic varies depending on the specific blockchain network. Nevertheless, a unified method to broadcast a signed transaction to the network is used.

To sign and broadcast a transaction to the Unified API supported network, follow these steps:

  1. Prepare unsigned transactions in Base64 encrypted format (unsignedTransactionData by default).
  2. Sign the transaction using the guides from the table below.
Blockchain networkUnified API chainSigning Instructions
Availavail🔗 Signing Instructions
Babylonbabylon-btc🔗 Signing Instructions
Ethereumeth_ssv🔗 Signing Instructions
Nearnear🔗 Signing Instructions
Solanasolana🔗 Signing Instructions
TONton_whales🔗 Signing Instructions
  1. Send the signed transaction to the network by making a POST request to /api/v1/unified/transaction/broadcast.

Example request (for solana chain and the testnet network):

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": "solana",
    "network": "testnet",
    "stakerAddress": "9FfyCk9kqgfpg1gYMw8rhksZcAg4JiD9xhuMvkFVdjQY",
    "signedTransaction": "AdtQhLeM0eOMdV7rvagYx3V8mra6CMaiVgeNTcgTds8ltjDUwJi3LMGhZ+Txqj26nJMJa7MxFWe5lmIxAnjKsQUBAAIEep+wazhVDEf2XiuHusgypzGMGyd4WaFZ6lzpHIypRJ3qFo72gQoaoUsCAJcUGGTQGdOONNYMBdVbIhEKwGitMwah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAABojzQ55lMuIXx6AWTccH48p4L12JlvUuCfHkOik1nJLAECAwEDAAQFAAAA"
}'
  • chain — blockchain network.
  • network — environment in which the transaction is processed: mainnet for production use; testnet for development and testing purposes.
  • stakerAddress — staking account address keeping the staked tokens.
  • 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.
    Example response (for solana chain and the testnet network):
{
    "error": null,
    "result": {
        "extraData": {
            "transactionId": "2Bno5j3tex8VmcCR2M6JQnjtPxDuqAvSAUjSDpd6gaasRfEQeoWH9MRQdU7ANNtFFbG9UQAGByG1UwPS1qersmyd",
            "slot": 307375529,
            "signerAccounts": [
                "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
                "6GtymMn8cDTy3xHH9AitwP6skbKvBkD53XBE2xSu1tCR",
                "11111111111111111111111111111111",
                "A93XLdBKfc4pwEMAvdFeyxnF6HauN5erNDFbUsemWiaB",
                "Stake11111111111111111111111111111111111111",
                "StakeConfig11111111111111111111111111111111",
                "SysvarC1ock11111111111111111111111111111111",
                "SysvarRent111111111111111111111111111111111",
                "SysvarStakeHistory1111111111111111111111111"
            ],
            "createdAt": "2024-12-17T19:41:27.450Z"
        }
    }
}
  • extraData — additional transaction details specific to the network.
  • createdAt — timestamp of the transaction in the ISO 8601 format.

What's Next?