event_signature_json

Returns EVM topic0 for an event described by JSON ABI; use it to filter or validate non-anonymous logs.

Example

Local

1
SELECT event_signature_json(json('{
2
"type": "event",
3
"name": "Transfer",
4
"inputs": [
5
{"indexed": true, "name": "from", "type": "address"},
6
{"indexed": true, "name": "to", "type": "address"},
7
{"indexed": false, "name": "value", "type": "uint256"}
8
]
9
}')) AS topic0;
10
-- ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
Notebook ready in readonly mode.

API reference

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

event_signature_json(JSON) #

Builds the canonical event signature from JSON ABI inputs before hashing with Keccak-256.

Inputs

Name Type Use
abi JSON

A single event ABI object with name and inputs. Indexed flags do not change the topic0 signature hash.

required positional

Returns

Name Type
signature BYTES32

Event topic0. Keccak-256 of the canonical event signature as BYTES32.

Guidance

Selector, topic0, calldata, and return data

Use event_signature or event_signature_json to build topic0 before filtering logs or validating decoded events. The JSON helper derives canonical input types and ignores names and indexed modifiers.

  • Anonymous logs omit topic0 even though this helper can still compute the event signature hash.
  • Indexed flags affect where values appear in log topics, but not the event signature hash.
  • The Transfer example is the USDC log at Ethereum block 20,000,000, transaction 0x5cbf...3dde, log index 97; its topics and data are reconstructed offline.
  • Use function_selector for the first four bytes of calldata.
  • Use error_selector for the first four bytes of custom error revert data.
  • Use event_decode_json when you already have topics and data to decode.

Local SQL

1
SELECT event_signature('Transfer(address,address,uint256)') AS topic0;
Notebook ready in readonly mode.

Related functions

Category and tags

Tag
ABI