githubEdit

broadcast_tx_commit - NEAR Protocol

Example code for the broadcast_tx_commit json-rpc method. Сomplete guide on how to use broadcast_tx_commit json-rpc in GetBlock.io Web3 documentation.

This method is used to send a signed transaction to the NEAR blockchain and wait until it is fully confirmed on-chain. Unlike /broadcast_tx_async, this endpoint waits for finalisation, returning the execution result of the transaction (success or failure).

Supported Network

  • Mainnet

Parameters Description

Parameter

Type

Required

Description

signed_tx_base64

string

Yes

The signed transaction, encoded in Base64 format.

Request Example

Base URL

   https://go.getblock.io/<ACCESS_TOKEN>

Example(cURL)

curl -X POST https://go.getblock.io/<ACCESS_TOKEN>\
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0",
"method": "broadcast_tx_commit",
"params": ["DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDQAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldIODI4YfV/QS++blXpQYT+bOsRblTRW4f547y/LkvMQ9AQAAAAMAAACh7czOG8LTAAAAAAAAAAXcaTJzu9GviPT7AD4mNJGY79jxTrjFLoyPBiLGHgBi8JK1AnhK8QknJ1ourxlvOYJA2xEZE8UR24THmSJcLQw="],
"id": "getblock.io"}'

Response

Response Parameters Definition

Field

Type

Description

status

object

Overall status of the transaction execution.

status.successValue

string

Amount successfully transferred or result of the execution.

transaction

object

The transaction object.

transaction.signer_id

string

Account ID of the transaction originator.

transaction.public_key

string

Public key of the signer.

transaction.nonce

string

Number of transactions previously sent by the sender (hexadecimal).

transaction.receiver_id

string

Account ID of the transaction receiver.

transaction.actions

array

List of actions included in the transaction (from near-api-js.transactions).

transaction.actions.transfer

object

Transfer action details.

transaction.actions.transfer.deposit

string

Amount of tokens being transferred.

transaction.signature

string

Standard ed25519 signature of the transaction.

transaction.hash

string

Hash of the transaction.

transaction_outcome

object

Result of the transaction execution.

transaction_outcome.proof

object

Proof of inclusion of the transaction in a block.

transaction_outcome.block_hash

string

Hash of the block that included this transaction.

transaction_outcome.id

string

Transaction ID.

transaction_outcome.outcome

object

Outcome details (execution result, logs, receipts).

transaction_outcome.outcome.logs

array

Logs generated during transaction execution.

transaction_outcome.outcome.receipt_ids

array

IDs of the receipts created by the transaction.

transaction_outcome.outcome.gas_burnt

string

Gas units consumed during execution.

transaction_outcome.outcome.tokens_burnt

string

Amount of NEAR tokens spent as gas.

transaction_outcome.outcome.executor_id

string

ID of the account executing the transaction.

transaction_outcome.outcome.status

object

Status of the transaction execution (SuccessValue, failure, etc.).

transaction_outcome.outcome.successReceiptId

string

Transaction ID of the successfully executed receipt.

transaction_outcome.receipts_outcome

array

Array of outcomes for all receipts generated by the transaction.

Use Cases

  • Execute smart contract functions (e.g., token transfers, staking operations).

  • Wait for transaction confirmation before updating app state.

  • Build transaction verification systems or block explorers.

  • Test contract calls in development networks (testnet).

Code Example

Node(Axios)

Python(Request)

Error Handling

HTTP Code

Error Message

Description

400 Bad Request

REQUEST_VALIDATION_ERROR

The provided Base64 transaction data is malformed or incomplete.

403 Forbidden

RBAC: access denied

The GetBlock API key is missing or invalid.

404 Not Found

REQUEST_VALIDATION_ERROR

The transaction expired.

500 Internal Server Error

Node error

The node failed to process or broadcast the transaction.

Integration with Web3

Integrating /broadcast_tx_commit into dApp, allows developers to:

  • Automatically verify transaction outcomes in Web3 applications.

  • Provide instant feedback to users after blockchain interactions.

  • Synchronise backend systems with confirmed on-chain events.

Last updated

Was this helpful?