View this page as Markdown

evm_decode_log_for

Returns a log diagnostic using the ABI registered locally for a chain, emitter, and block; use it when ABI selection depends on contract context.

Example

Local

WITH registered AS MATERIALIZED (
  SELECT evm_register_contract_abi(
    1,
    '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'::ADDRESS,
    '[{"type":"event","name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}]}]'::JSON,
    'USDC at block 20,000,000',
    20000000,
    20000000
  ) AS ok
)
SELECT evm_decode_log_for(
  1,
  '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'::ADDRESS,
  20000000,
  [
    event_signature('Transfer(address,address,uint256)'),
    evm_abi_word('0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472'::ADDRESS),
    evm_abi_word('0xa1db2fc9b2ceaf3cdf41fd11ffcb38404eae3906'::ADDRESS)
  ],
  evm_abi_word(615568393::UINT256)::BYTES
) AS diagnostic
FROM registered
WHERE ok;
-- diagnostic.name = Transfer

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

evm_decode_log_for(UBIGINT, ADDRESS, UBIGINT, BYTES32[], BYTES) #

Looks up ABI metadata for the emitting contract context, then decodes the log.

Note: The contract ABI must already be registered.

Inputs

Name Type Use
chain_id UBIGINT

Chain id used to resolve registered ABI metadata.

required positional
address ADDRESS

Log-emitting contract address.

required positional
block_number UBIGINT

Block number for ABI registry validity range selection.

required positional
topics BYTES32[]

Event topics as BYTES32 values, including topic0.

required positional
data BYTES

Raw event data bytes.

required positional

Returns

Name Type
diagnostic JSON

Contextual log diagnostic JSON. Uses log_decode_json shapes; decoded results add abi_label when the registration has a label.

Guidance

Decode with local contract context

The function reads only the current database's ABI registry. Validity endpoints are inclusive, and a NULL endpoint in a registration is unbounded.

  • Register the emitter ABI before decoding. Required NULL inputs propagate NULL.
  • If no registration matches, the result is unknown and retains topic0, every topic, data, and padded data_words.

Related functions

Category and tags

Tag
ABI
Tag
Events
Tag
Evidence