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

1
WITH registered AS MATERIALIZED (
2
SELECT evm_register_contract_abi(
3
1,
4
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'::ADDRESS,
5
'[{"type":"event","name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"recipient","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}]}]'::JSON,
6
'USDC at block 20,000,000',
7
20000000,
8
20000000
9
) AS ok
10
)
11
SELECT evm_decode_log_for(
12
1,
13
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'::ADDRESS,
14
20000000,
15
[
16
event_signature('Transfer(address,address,uint256)'),
17
evm_abi_word('0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472'::ADDRESS),
18
evm_abi_word('0xa1db2fc9b2ceaf3cdf41fd11ffcb38404eae3906'::ADDRESS)
19
],
20
evm_abi_word(615568393::UINT256)::BYTES
21
) AS diagnostic
22
FROM registered
23
WHERE ok;
24
-- diagnostic.name = Transfer
Notebook ready in readonly mode.

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