event_decode_json

Returns decoded EVM event arguments as compact JSON; use it for already-materialized topics and data when malformed input should produce NULL.

Scalar function ABILogsInspectionRPC

Example

Runs locally

-- Decode a USDC Transfer log to JSON with a JSON event ABI
SELECT event_decode_json(
  '{"type":"event","name":"Transfer","inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"recipient","type":"address"},{"indexed":false,"name":"value","type":"uint256"}]}'::JSON,
  [
    event_signature('Transfer(address,address,uint256)'),
    evm_abi_word('0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472'::ADDRESS),
    evm_abi_word('0xa1db2fc9b2ceaf3cdf41fd11ffcb38404eae3906'::ADDRESS)
  ],
  evm_abi_word(615568393::UINT256)::BLOB
) AS decoded_event;
-- decoded_event.sender = 0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472

API reference

event_decode_json(JSON, BYTES32[], BLOB) #

Accepts a JSON ABI event fragment.

Inputs

Name Type Use
event_abi JSON

Single event ABI object with indexed flags and input types.

required positional
topics BYTES32[]

LIST of BYTES32 values. For non-anonymous events, the first list element is EVM topic0; anonymous events begin with the first indexed argument.

required positional
data BLOB

ABI-encoded non-indexed event data as BLOB.

required positional

Returns

Name Type
decoded_event JSON

Decoded event JSON. Returns values keyed by ABI input name. Unnamed inputs use arg_0, arg_1, and so on; booleans and lists remain JSON, EVM BLOB-backed values are 0x strings, and other scalars are strings.

event_decode_json(VARCHAR, BYTES32[], BLOB) #

Accepts a JSON ABI event fragment as VARCHAR.

Inputs

Name Type Use
event_abi VARCHAR

Single JSON ABI event object supplied explicitly as VARCHAR.

required positional
topics BYTES32[]

LIST of BYTES32 values. For non-anonymous events, the first list element is EVM topic0; anonymous events begin with the first indexed argument.

required positional
data BLOB

ABI-encoded non-indexed event data as BLOB.

required positional

Returns

Name Type
decoded_event JSON

Decoded event JSON. Returns values keyed by ABI input name. Unnamed inputs use arg_0, arg_1, and so on; booleans and lists remain JSON, EVM BLOB-backed values are 0x strings, and other scalars are strings.

Overload examples

Runs locally

-- Decode a USDC Transfer log to JSON from VARCHAR
SELECT event_decode_json(
  '{"type":"event","name":"Transfer","inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"recipient","type":"address"},{"indexed":false,"name":"value","type":"uint256"}]}'::VARCHAR,
  [
    event_signature('Transfer(address,address,uint256)'),
    evm_abi_word('0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472'::ADDRESS),
    evm_abi_word('0xa1db2fc9b2ceaf3cdf41fd11ffcb38404eae3906'::ADDRESS)
  ],
  evm_abi_word(615568393::UINT256)::BLOB
) AS decoded_event;
-- decoded_event.sender = 0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472

Guidance

Decode logs offline

Use event_decode_json when topics and data are already available from get_logs, get_transaction_logs, or a fixture. The ABI event fragment controls how indexed topics and data words are decoded.

  • For a non-anonymous event, the first topic should be event_signature('EventName(types...)'). Anonymous events omit topic0 and begin with their first indexed parameter.
  • The canonical sample reconstructs USDC transaction 0x5cbf...3dde, log index 97, at Ethereum block 20,000,000 without an RPC call.
  • Indexed addresses are stored as left-padded BYTES32 topics.
  • Indexed dynamic values are represented by their indexed topic hash.
  • Non-indexed values are decoded from the data BLOB. A mismatched non-anonymous topic0 is currently not rejected.
  • Malformed ABI, topics, or data return NULL instead of raising a decode error.