sendTransaction - Stellar

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

This method submits a signed transaction to the Stellar network. Unlike Horizon, this method does not wait for confirmation; use getTransaction to track the outcome.

Parameters

Parameter
Type
Description

transaction

string

Signed transaction envelope (base64-encoded XDR)

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "sendTransaction",
    "params": {
        "transaction": "AAAAAgAAAAAg4dbAxsGAGICfBG3iT2cKGYQ6hK4sJWzZ6or1C5v6GAAAAGQAJsOiAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACgAAAAVIZWxsbwAAAAAAAAEAAAAMU29yb2JhbiBEb2NzAAAAAAAAAAELm/oYAAAAQATr6Ghp/DNO7S6JjEFwcJ9a+dvI6NJr7I/2eQttvoovjQ8te4zKKaapC3mbmx6ld6YKL5T81mxs45TjzdG5zw0="
    },
    "id": "getblock.io"
}'

Response

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "status": "PENDING",
        "hash": "d8ec9b68780314ffdfdfc2194b1b35dd27d7303c3bceaef6447e31631a1419dc",
        "latestLedger": 2553978,
        "latestLedgerCloseTime": "1700159337"
    }
}

Response Parameters

Field
Type
Description

status

string

Transaction status (PENDING, DUPLICATE, TRY_AGAIN_LATER, ERROR)

hash

string

Transaction hash

latestLedger

integer

Latest ledger at time of submission

latestLedgerCloseTime

string

Unix timestamp of latest ledger close

errorResultXdr

string

(optional) Error details if status is ERROR

Use Case

The sendTransaction method is essential for:

  • Submitting payments

  • Smart contract invocations

  • Asset transfers

  • Account operations

  • Trustline management

  • DEX order submission

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS-TOKEN

-32602

Invalid params

Invalid transaction format

ERROR

Transaction failed

Invalid signature, insufficient balance, etc.

Last updated

Was this helpful?