tx - Cosmos

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

Returns a transaction by its hash, with optional Merkle proof of inclusion. The hash is the hex-encoded SHA-256 of the canonical transaction bytes (uppercase, no 0x prefix).

Parameters

Parameter
Type
Required
Description

hash

string

Yes

Transaction hash (uppercase hex, 32 bytes)

prove

boolean

No

If true, include the inclusion Merkle proof (default: false)

Request Example

# JSON-RPC over HTTP POST (canonical)
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "tx",
    "params": {
        "hash": "B5C8E4F1A6D3B9C2E5F8A1D4B7C0E3F6A9D2B5C8E1F4A7D0B3C6E9F2A5D8B1C4",
        "prove": false
    },
    "id": "getblock.io"
}'

# URI over HTTP GET (alternate, for simple methods)
curl --location --request GET 'https://go.getblock.io/<ACCESS-TOKEN>/tx?hash="B5C8E4F1A6D3B9C2E5F8A1D4B7C0E3F6A9D2B5C8E1F4A7D0B3C6E9F2A5D8B1C4"&prove=false'

Response Example

Response Parameters

Field
Type
Description

result.hash

string

Transaction hash (echoed)

result.height

string

Block height that included this transaction

result.index

integer

Index of the transaction within the block

result.tx_result.code

integer

ABCI response code: 0 for success, non-zero for failure

result.tx_result.gas_used

string

Actual gas consumed

result.tx_result.events

array

Events emitted by the transaction

result.tx

string

Base64-encoded transaction bytes

Use Cases

  • Looking up a transaction after broadcast to confirm inclusion

  • Wallet history flows showing past transactions by hash

  • Decoding transaction details for explorers

Error Handling

Status Code
Error Message
Cause

404

Not Found

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

-32603

Internal error

Server-side error while processing the request

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?