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 or hex-encoded format (unsignedTransactionData by default).
  2. Sign the transaction using the guides from the table below.

Blockchain network

Unified API chain

Signing Instructions

Aptos

aptos

🔗 Signing Instructions

Avail

avail

🔗 Signing Instructions

Babylon (BTC)

babylon-btc

🔗 Signing Instructions

Babylon Genesis (BABY)

babylon

Cardano

cardano

🔗 Signing Instructions

Celestia

celestia

Cosmos

cosmos

dYdX

dydx

🔗 Signing Instructions

Ethereum

eth_ssv

🔗 Signing Instructions

Hyperliquid

hyperliquid

🔗 Signing Instructions

Near

near

🔗 Signing Instructions

Polkadot

polkadot

🔗 Signing Instructions

Polygon

polygon

🔗 Signing Instructions

Sei

sei

🔗 Signing Instructions

Solana

solana

🔗 Signing Instructions

Sui

sui

🔗 Signing Instructions

Story Protocol

story

🔗 Signing Instructions

Tezos

xtz

🔗 Signing Instructions

The Graph

grt

🔗 Signing Instructions

TON

ton_whales

🔗 Signing Instructions

Tron

tron

🔗 Signing Instructions

  1. Broadcast the signed transaction to the network by sending a POST request to /api/v1/unified/transaction/broadcast.

Example request (for solana chain and 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.
  • 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 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:
    • transactionId — block hash in which the transaction has been included.
    • slot — period of time during which each leader collects transactions and creates a block in the Solana network.
    • signerAccounts — account addresses that signed the transaction.
    • createdAt — timestamp of the transaction in the ISO 8601 format.

What's Next?