get_transaction

Fetches a transaction by hash, then makes a separate receipt request for receipt metadata.

Table functionLive RPC RPC

Example

Live RPC

-- Block, sender, recipient and receipt status of one transaction
SELECT block_number, "from" AS sender, "to" AS recipient, receipt_status, gas_used
FROM get_transaction(
  $client,
  '0x9517e2bc102ae3cde3963c2d2811b64402c3ddaa562206a42a0a1472aadd93a4'::BYTES32
);

API reference

get_transaction(CLIENT, BYTES32) # RPC required

Accepts a transaction hash as an exact BYTES32 value.

Inputs

Name Type Use
client CLIENT

Attached live CLIENT for the chain where the transaction exists.

required positional
tx_hash BYTES32

Transaction hash as BYTES32 or a VARCHAR containing exactly 64 hexadecimal digits, with an optional 0x or 0X prefix.

required positional

Result columns

NameType
hashBYTES32

Transaction hash.

block_hashBYTES32

Containing block hash; NULL when pending.

block_numberBLOCK_NUMBER

Containing block height; NULL when pending.

transaction_indexINTEGER

Position within the block.

fromADDRESS

Sender address.

Transaction and receipt metadata. Returns one row per input hash. Receipt columns are NULL when the receipt request fails or has no result. If the client or transaction result is unavailable, every column in the row is NULL.

get_transaction(CLIENT, VARCHAR) # RPC required

Accepts exactly 64 hexadecimal digits with an optional 0x or 0X prefix; other values are rejected.

Inputs

Name Type Use
client CLIENT

Attached live CLIENT for the chain where the transaction exists.

required positional
tx_hash VARCHAR

Transaction hash as BYTES32 or a VARCHAR containing exactly 64 hexadecimal digits, with an optional 0x or 0X prefix.

required positional

Result columns

NameType
hashBYTES32

Transaction hash.

block_hashBYTES32

Containing block hash; NULL when pending.

block_numberBLOCK_NUMBER

Containing block height; NULL when pending.

transaction_indexINTEGER

Position within the block.

fromADDRESS

Sender address.

Transaction and receipt metadata. Returns one row per input hash. Receipt columns are NULL when the receipt request fails or has no result. If the client or transaction result is unavailable, every column in the row is NULL.

Guidance

Snapshot and receipt context

Transaction hashes are chain-scoped. Use a CLIENT for the chain where the transaction was submitted.

Receipt fields can be absent while a transaction is pending or when the receipt request fails.

Persist block_number and block_hash when later queries must use the same mined snapshot.

Transaction evidence

Pair get_transaction with get_transaction_logs when analysis needs both transaction metadata and emitted events.