For the complete documentation index, see llms.txt. This page is also available as Markdown.

send_transaction - Nervos

Example code for the send_transaction JSON-RPC method. Complete guide on how to use send_transaction JSON-RPC in GetBlock Web3 documentation.

Submits a new transaction to the tx pool. Returns the transaction hash. Uses passthrough (default) for outputs validator — pass well_known_scripts_only to enforce that all outputs use well-known lock scripts (a basic safety check).

Parameters

Parameter
Type
Required
Description

tx

Transaction

Yes

Signed transaction

outputs_validator

string

No

passthrough (default) or well_known_scripts_only

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "send_transaction",
    "params": [
        {
            "version": "0x0",
            "cell_deps": [],
            "header_deps": [],
            "inputs": [],
            "outputs": [],
            "outputs_data": [],
            "witnesses": []
        },
        "passthrough"
    ],
    "id": "getblock.io"
}'
import axios from 'axios';

const data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "send_transaction",
    "params": [
        {
            "version": "0x0",
            "cell_deps": [],
            "header_deps": [],
            "inputs": [],
            "outputs": [],
            "outputs_data": [],
            "witnesses": []
        },
        "passthrough"
    ],
    "id": "getblock.io"
});

const config = {
    method: 'post',
    url: 'https://go.getblock.io/<ACCESS-TOKEN>/',
    headers: {
        'Content-Type': 'application/json'
    },
    data: data
};

axios(config)
    .then(response => console.log(JSON.stringify(response.data, null, 2)))
    .catch(error => console.log(error));

Response Example

Response Parameters

Field
Type
Description

result

H256

Transaction hash — use get_transaction to track inclusion

Use Cases

  • Wallet transaction submission

  • DEX backends submitting orders

  • Cross-chain bridge relayer transaction submission

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

-32601

Method not found

Method does not exist or is not enabled on this node

-32603

Internal error

Server-side error while processing the request

429

Too Many Requests

Rate limit exceeded for your plan

-1000 to -1099

PoolRejectedTransactionByOutputsValidator

Transaction rejected by output validator (use passthrough if you know what you're doing)

-1101

PoolRejectedTransactionByIllTransactionChecker

Transaction contains malformed components

-1102

PoolRejectedTransactionByMinFeeRate

Fee rate below the minimum

-1103

PoolRejectedTransactionByMaxAncestorsCountLimit

Transaction chain exceeds the ancestors limit

-1104

PoolIsFull

The mempool is full

-1105

PoolRejectedDuplicatedTransaction

Transaction is already in the pool

SDK Integration

Was this helpful?