Skip to main content

Transactions

The RPC API enables you to send transactions and query their status on the NEAR blockchain. This includes sending new transactions, checking transaction status, retrieving receipts, and monitoring transaction execution.


Quick Reference

MethodParametersDescription
send_txsigned_tx_base64, wait_untilSend a transaction and optionally wait for execution
txtx_hash, sender_account_id, wait_untilQuery transaction status by hash
EXPERIMENTAL_tx_statustx_hash, sender_account_id, wait_untilQuery transaction status with receipt details
EXPERIMENTAL_receiptreceipt_idFetch receipt by ID
broadcast_tx_asyncsigned_tx_base64(Deprecated) Send transaction asynchronously
broadcast_tx_commitsigned_tx_base64(Deprecated) Send transaction and wait for completion

Send transaction

Description

Sends transaction. Returns the guaranteed execution status and the results the blockchain can provide at the moment.

  • method: send_tx
  • params:
    • signed_tx_base64: SignedTransaction encoded in base64
    • [Optional] wait_until: the required minimal execution level. The default value is EXECUTED_OPTIMISTIC. Read more here.

Using send_tx with wait_until = NONE is equal to legacy broadcast_tx_async method.
Using send_tx with finality wait_until = EXECUTED_OPTIMISTIC is equal to legacy broadcast_tx_commit method.

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "send_tx",
"params": {
"signed_tx_base64": "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=",
"wait_until": "INCLUDED_FINAL"
}
}
Example response:
{
"jsonrpc": "2.0",
"result": {
"final_execution_status": "FINAL",
"status": {
"SuccessValue": ""
},
"transaction": {
"signer_id": "sender.testnet",
"public_key": "ed25519:Gowpa4kXNyTMRKgt5W7147pmcc2PxiFic8UHW9rsNvJ6",
"nonce": 13,
"receiver_id": "receiver.testnet",
"actions": [
{
"Transfer": {
"deposit": "1000000000000000000000000"
}
}
],
"signature": "ed25519:7oCBMfSHrZkT7tzPDBxxCd3tWFhTES38eks3MCZMpYPJRfPWKxJsvmwQiVBBxRLoxPTnXVaMU2jPV3MdFKZTobH",
"hash": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR"
},
"transaction_outcome": {
"proof": [],
"block_hash": "9MzuZrRPW1BGpFnZJUJg6SzCrixPpJDfjsNeUobRXsLe",
"id": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR",
"outcome": {
"logs": [],
"receipt_ids": ["BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh"],
"gas_burnt": 223182562500,
"tokens_burnt": "22318256250000000000",
"executor_id": "sender.testnet",
"status": {
"SuccessReceiptId": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh"
}
}
},
"receipts_outcome": [
{
"proof": [],
"block_hash": "5Hpj1PeCi32ZkNXgiD1DrW4wvW4Xtic74DJKfyJ9XL3a",
"id": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh",
"outcome": {
"logs": [],
"receipt_ids": ["3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR"],
"gas_burnt": 223182562500,
"tokens_burnt": "22318256250000000000",
"executor_id": "receiver.testnet",
"status": {
"SuccessValue": ""
}
}
}
]
},
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.


Transaction Status

Description

Queries status of a transaction by hash and returns the final transaction result.

  • method: tx
  • params:
    • tx_hash (see NearBlocks Explorer for a valid transaction hash)
    • sender_account_id (used to determine which shard to query for transaction)
    • [Optional] wait_until: the required minimal execution level. The default value is EXECUTED_OPTIMISTIC. Read more here.

A Transaction status request with wait_until != NONE will wait until the transaction appears on the blockchain. If the transaction does not exist, the method will wait until the timeout is reached. If you only need to check whether the transaction exists, use wait_until = NONE, it will return the response immediately.

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "tx",
"params": {
"tx_hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1",
"sender_account_id": "rpc-examples.testnet",
"wait_until": "FINAL"
}
}
Example response:
{
"jsonrpc": "2.0",
"result": {
"final_execution_status": "FINAL",
"receipts_outcome": [
{
"block_hash": "ApNYvBCU3Nnn8TeESvJ7Anfw8vfbmwcXmavypAWtKv6p",
"id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE",
"outcome": {
"executor_id": "contract.rpc-examples.testnet",
"gas_burnt": 4174947687500,
"logs": [],
"metadata": {
"gas_profile": [],
"version": 3
},
"receipt_ids": ["AZz7tN4cSK9Ngeq7KUFWSm8yi9WLsVjqYiohNYzW8Pc4"],
"status": {
"SuccessValue": ""
},
"tokens_burnt": "417494768750000000000"
},
"proof": [
{
"direction": "Left",
"hash": "CuLK7PnND8x1XooFysdUbG9VqG2yzKKjPSFXSGsuKzn4"
}
]
}
],
"status": {
"SuccessValue": ""
},
"transaction": {
"actions": [
"CreateAccount",
{
"Transfer": {
"deposit": "5000000000000000000000000"
}
},
{
"AddKey": {
"access_key": {
"nonce": 0,
"permission": "FullAccess"
},
"public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M"
}
}
],
"hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1",
"nonce": 187307146000001,
"priority_fee": 0,
"public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M",
"receiver_id": "contract.rpc-examples.testnet",
"signature": "ed25519:34NgQAukvyKajXFDB6XzKpfd2YDUo3QyTdkUeCgwm24J3dkju7Ejm71VRkRsJwdpKwH1HQWqSV2frnF26yQYEZpJ",
"signer_id": "rpc-examples.testnet"
},
"transaction_outcome": {
"block_hash": "G1xSnhtrDiaEZNef41kiY8ePQCAwsF2gyVcRNa7B6xaP",
"id": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1",
"outcome": {
"executor_id": "rpc-examples.testnet",
"gas_burnt": 4174947687500,
"logs": [],
"metadata": {
"gas_profile": null,
"version": 1
},
"receipt_ids": ["23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE"],
"status": {
"SuccessReceiptId": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE"
},
"tokens_burnt": "417494768750000000000"
},
"proof": [
{
"direction": "Left",
"hash": "Ft2GVFu6zuQGbUU7DB7opgshYLPvuvfNnGqMAny1kgPj"
}
]
}
},
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.


Transaction Status with Receipts

Description

Queries status of a transaction by hash, returning the final transaction result and details of all receipts.

  • method: EXPERIMENTAL_tx_status
  • params:
    • tx_hash (see NearBlocks Explorer for a valid transaction hash)
    • sender_account_id (used to determine which shard to query for transaction)
    • [Optional] wait_until: the required minimal execution level. The default value is EXECUTED_OPTIMISTIC. Read more here.

A Transaction status request with wait_until != NONE will wait until the transaction appears on the blockchain. If the transaction does not exist, the method will wait until the timeout is reached. If you only need to check whether the transaction exists, use wait_until = NONE, it will return the response immediately.

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "EXPERIMENTAL_tx_status",
"params": {
"tx_hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1",
"sender_account_id": "rpc-examples.testnet",
"wait_until": "FINAL"
}
}
Example response:
{
"jsonrpc": "2.0",
"result": {
"final_execution_status": "FINAL",
"receipts": [
{
"predecessor_id": "rpc-examples.testnet",
"priority": 0,
"receipt": {
"Action": {
"actions": [
"CreateAccount",
{
"Transfer": {
"deposit": "5000000000000000000000000"
}
},
{
"AddKey": {
"access_key": {
"nonce": 0,
"permission": "FullAccess"
},
"public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M"
}
}
],
"gas_price": "103000000",
"input_data_ids": [],
"is_promise_yield": false,
"output_data_receivers": [],
"signer_id": "rpc-examples.testnet",
"signer_public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M"
}
},
"receipt_id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE",
"receiver_id": "contract.rpc-examples.testnet"
},
{
"predecessor_id": "system",
"priority": 0,
"receipt": {
"Action": {
"actions": [
{
"Transfer": {
"deposit": "12524843062500000000"
}
}
],
"gas_price": "0",
"input_data_ids": [],
"is_promise_yield": false,
"output_data_receivers": [],
"signer_id": "rpc-examples.testnet",
"signer_public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M"
}
},
"receipt_id": "AZz7tN4cSK9Ngeq7KUFWSm8yi9WLsVjqYiohNYzW8Pc4",
"receiver_id": "rpc-examples.testnet"
}
],
"receipts_outcome": [
{
"block_hash": "ApNYvBCU3Nnn8TeESvJ7Anfw8vfbmwcXmavypAWtKv6p",
"id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE",
"outcome": {
"executor_id": "contract.rpc-examples.testnet",
"gas_burnt": 4174947687500,
"logs": [],
"metadata": {
"gas_profile": [],
"version": 3
},
"receipt_ids": ["AZz7tN4cSK9Ngeq7KUFWSm8yi9WLsVjqYiohNYzW8Pc4"],
"status": {
"SuccessValue": ""
},
"tokens_burnt": "417494768750000000000"
},
"proof": [
{
"direction": "Left",
"hash": "CuLK7PnND8x1XooFysdUbG9VqG2yzKKjPSFXSGsuKzn4"
}
]
},
{
"block_hash": "4C1384HReTY7NR7jVk2aMDyccCNVM5zeQDQ6z84cj1N4",
"id": "AZz7tN4cSK9Ngeq7KUFWSm8yi9WLsVjqYiohNYzW8Pc4",
"outcome": {
"executor_id": "rpc-examples.testnet",
"gas_burnt": 223182562500,
"logs": [],
"metadata": {
"gas_profile": [],
"version": 3
},
"receipt_ids": [],
"status": {
"SuccessValue": ""
},
"tokens_burnt": "0"
},
"proof": [
{
"direction": "Left",
"hash": "7agjDTstRCDmAn4LvPnHDu8yxhbSWCD7VNhzr7nLq37N"
},
{
"direction": "Left",
"hash": "54QAYN39nMUp6uz6vhNbDNRbvAmk16mw7R1WvxnmG1Xr"
}
]
}
],
"status": {
"SuccessValue": ""
},
"transaction": {
"actions": [
"CreateAccount",
{
"Transfer": {
"deposit": "5000000000000000000000000"
}
},
{
"AddKey": {
"access_key": {
"nonce": 0,
"permission": "FullAccess"
},
"public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M"
}
}
],
"hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1",
"nonce": 187307146000001,
"priority_fee": 0,
"public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M",
"receiver_id": "contract.rpc-examples.testnet",
"signature": "ed25519:34NgQAukvyKajXFDB6XzKpfd2YDUo3QyTdkUeCgwm24J3dkju7Ejm71VRkRsJwdpKwH1HQWqSV2frnF26yQYEZpJ",
"signer_id": "rpc-examples.testnet"
},
"transaction_outcome": {
"block_hash": "G1xSnhtrDiaEZNef41kiY8ePQCAwsF2gyVcRNa7B6xaP",
"id": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1",
"outcome": {
"executor_id": "rpc-examples.testnet",
"gas_burnt": 4174947687500,
"logs": [],
"metadata": {
"gas_profile": null,
"version": 1
},
"receipt_ids": ["23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE"],
"status": {
"SuccessReceiptId": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE"
},
"tokens_burnt": "417494768750000000000"
},
"proof": [
{
"direction": "Left",
"hash": "Ft2GVFu6zuQGbUU7DB7opgshYLPvuvfNnGqMAny1kgPj"
},
{
"direction": "Left",
"hash": "39hCSJBs64y18wcM8qtasQQnkfXYBhvHau3bEbULgV3E"
},
{
"direction": "Right",
"hash": "GkZCCuNqu2qpwd5Xwo2g4qwRvXXmgV2k71YM7EYhg5HK"
}
]
}
},
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.


Receipt by ID

Description

Fetches a receipt by its ID (as is, without a status or execution outcome)

  • method: EXPERIMENTAL_receipt
  • params:

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "EXPERIMENTAL_receipt",
"params": {
"receipt_id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE"
}
}
Example response:
{
"jsonrpc": "2.0",
"result": {
"predecessor_id": "rpc-examples.testnet",
"priority": 0,
"receipt": {
"Action": {
"actions": [
"CreateAccount",
{
"Transfer": {
"deposit": "5000000000000000000000000"
}
},
{
"AddKey": {
"access_key": {
"nonce": 0,
"permission": "FullAccess"
},
"public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M"
}
}
],
"gas_price": "103000000",
"input_data_ids": [],
"is_promise_yield": false,
"output_data_receivers": [],
"signer_id": "rpc-examples.testnet",
"signer_public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M"
}
},
"receipt_id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE",
"receiver_id": "contract.rpc-examples.testnet"
},
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.


Transaction Execution Levels

All the methods listed above have wait_until request parameter, and final_execution_status response value. They correspond to the same enum TxExecutionStatus. See the detailed explanation for all the options:

#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum TxExecutionStatus {
/// Transaction is waiting to be included into the block
None,
/// Transaction is included into the block. The block may be not finalized yet
Included,
/// Transaction is included into the block +
/// All non-refund transaction receipts finished their execution.
/// The corresponding blocks for tx and each receipt may be not finalized yet
#[default]
ExecutedOptimistic,
/// Transaction is included into finalized block
IncludedFinal,
/// Transaction is included into finalized block +
/// All non-refund transaction receipts finished their execution.
/// The corresponding blocks for each receipt may be not finalized yet
Executed,
/// Transaction is included into finalized block +
/// Execution of all transaction receipts is finalized, including refund receipts
Final,
}

Deprecated methods

[deprecated] Send transaction (async)

Description

Consider using send_tx instead

Sends a transaction and immediately returns transaction hash.

  • method: broadcast_tx_async
  • params: [SignedTransaction encoded in base64]

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "broadcast_tx_async",
"params": [
"DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE="
]
}
Example response:
{
"jsonrpc": "2.0",
"result": "9yzcZFHqtKqTUPnz9dx2DfTjDnFemPEQjbgVqSBdnvKr",
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.

Final transaction results can be queried using Transaction Status or NearBlocks Explorer using the above result hash returning a result similar to the example below.

NEAR-Explorer-transactionHash


[deprecated] Send transaction (await)

Description

Consider using send_tx instead

Sends a transaction and waits until transaction is fully complete. (Has a 10 second timeout)

  • method: broadcast_tx_commit
  • params: [SignedTransaction encoded in base64]

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "broadcast_tx_commit",
"params": [
"DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDQAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldIODI4YfV/QS++blXpQYT+bOsRblTRW4f547y/LkvMQ9AQAAAAMAAACh7czOG8LTAAAAAAAAAAXcaTJzu9GviPT7AD4mNJGY79jxTrjFLoyPBiLGHgBi8JK1AnhK8QknJ1ourxlvOYJA2xEZE8UR24THmSJcLQw="
]
}
Example response:
{
"jsonrpc": "2.0",
"result": {
"final_execution_status": "FINAL",
"status": {
"SuccessValue": ""
},
"transaction": {
"signer_id": "sender.testnet",
"public_key": "ed25519:Gowpa4kXNyTMRKgt5W7147pmcc2PxiFic8UHW9rsNvJ6",
"nonce": 13,
"receiver_id": "receiver.testnet",
"actions": [
{
"Transfer": {
"deposit": "1000000000000000000000000"
}
}
],
"signature": "ed25519:7oCBMfSHrZkT7tzPDBxxCd3tWFhTES38eks3MCZMpYPJRfPWKxJsvmwQiVBBxRLoxPTnXVaMU2jPV3MdFKZTobH",
"hash": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR"
},
"transaction_outcome": {
"proof": [],
"block_hash": "9MzuZrRPW1BGpFnZJUJg6SzCrixPpJDfjsNeUobRXsLe",
"id": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR",
"outcome": {
"logs": [],
"receipt_ids": ["BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh"],
"gas_burnt": 223182562500,
"tokens_burnt": "22318256250000000000",
"executor_id": "sender.testnet",
"status": {
"SuccessReceiptId": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh"
}
}
},
"receipts_outcome": [
{
"proof": [],
"block_hash": "5Hpj1PeCi32ZkNXgiD1DrW4wvW4Xtic74DJKfyJ9XL3a",
"id": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh",
"outcome": {
"logs": [],
"receipt_ids": ["3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR"],
"gas_burnt": 223182562500,
"tokens_burnt": "22318256250000000000",
"executor_id": "receiver.testnet",
"status": {
"SuccessValue": ""
}
}
}
]
},
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.


Error Handling

Common Error Types

Error CodeDescriptionSolution
UnknownTransactionTransaction not foundVerify transaction hash and sender account
TimeoutErrorTransaction timeoutUse appropriate wait_until parameter or retry
InvalidTransactionInvalid transaction formatCheck transaction structure and signature
InvalidAccountInvalid account formatUse valid account ID format (e.g., account.near)
InsufficientStakeNot enough stake for operationEnsure account has sufficient NEAR tokens
MethodNotFoundInvalid method nameCheck method spelling and API version
ParseErrorJSON parsing errorVerify JSON format and structure
ServerErrorInternal server errorRetry request or use different RPC endpoint

Best Practices

  • Use appropriate wait_until levels: Choose the right execution level based on your requirements

    • NONE: For fire-and-forget scenarios
    • INCLUDED: When you need confirmation the transaction is in a block
    • EXECUTED_OPTIMISTIC: For most use cases (default)
    • FINAL: When you need absolute finality guarantees
  • Handle timeouts gracefully: Implement proper timeout handling and retry logic

  • Monitor gas usage: Track gas consumption to optimize transaction costs

  • Batch operations: When possible, batch multiple actions in a single transaction