evm_register_contract_abi

Stores contract ABI metadata in the current database for block-aware log and revert decoding.

Example

Runs locally

-- Register a Transfer event ABI for one contract on chain 1
SELECT evm_register_contract_abi(
  1,
  '0x0000000000000000000000000000000000000500'::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
) AS registered;
-- true

API reference

evm_register_contract_abi(UBIGINT, ADDRESS, JSON) #

Registers one local ABI and optional inclusive validity range.

Inputs

Name Type Use
chain_id UBIGINT

Chain id.

required positional
address ADDRESS

Contract address.

required positional
abi JSON

Contract ABI JSON.

required positional

Returns

Name Type
registered BOOLEAN

Registration status. Returns true when canonicalized ABI metadata is inserted or when the exact registration is replayed. A successful call never returns false.

evm_register_contract_abi(UBIGINT, ADDRESS, JSON, VARCHAR) #

Registers one local ABI and optional inclusive validity range.

Inputs

Name Type Use
chain_id UBIGINT

Chain id.

required positional
address ADDRESS

Contract address.

required positional
abi JSON

Contract ABI JSON.

required positional
label VARCHAR

Optional ABI label.

required positional

Returns

Name Type
registered BOOLEAN

Registration status. Returns true when canonicalized ABI metadata is inserted or when the exact registration is replayed. A successful call never returns false.

Overload examples

Runs locally

-- Register a Transfer event ABI for one contract on chain 1
SELECT evm_register_contract_abi(
  1,
  '0x0000000000000000000000000000000000000501'::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 Transfer'
) AS registered;
-- true
evm_register_contract_abi(UBIGINT, ADDRESS, JSON, VARCHAR, UBIGINT) #

Registers one local ABI and optional inclusive validity range.

Inputs

Name Type Use
chain_id UBIGINT

Chain id.

required positional
address ADDRESS

Contract address.

required positional
abi JSON

Contract ABI JSON.

required positional
label VARCHAR

Optional ABI label.

required positional
from_block UBIGINT

First valid block (inclusive).

required positional

Returns

Name Type
registered BOOLEAN

Registration status. Returns true when canonicalized ABI metadata is inserted or when the exact registration is replayed. A successful call never returns false.

Overload examples

Runs locally

-- Register a Transfer event ABI for one contract on chain 1
SELECT evm_register_contract_abi(
  1,
  '0x0000000000000000000000000000000000000502'::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 Transfer',
  20000000
) AS registered;
-- true
evm_register_contract_abi(UBIGINT, ADDRESS, JSON, VARCHAR, UBIGINT, UBIGINT) #

Registers one local ABI and optional inclusive validity range.

Inputs

Name Type Use
chain_id UBIGINT

Chain id.

required positional
address ADDRESS

Contract address.

required positional
abi JSON

Contract ABI JSON.

required positional
label VARCHAR

Optional ABI label.

required positional
from_block UBIGINT

First valid block (inclusive).

required positional
to_block UBIGINT

Final valid block (inclusive).

required positional

Returns

Name Type
registered BOOLEAN

Registration status. Returns true when canonicalized ABI metadata is inserted or when the exact registration is replayed. A successful call never returns false.

Overload examples

Runs locally

-- Register a Transfer event ABI for one contract on chain 1
SELECT evm_register_contract_abi(
  1,
  '0x0000000000000000000000000000000000000503'::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 Transfer',
  20000000,
  20000000
) AS registered;
-- true

Guidance

Register contextual ABI metadata

Registrations are stored only in the current database and are read by evm_decode_log_for and evm_decode_revert_for.

from_block and to_block are inclusive. A missing endpoint is unbounded.

ABI JSON is canonicalized before identity hashing. Replaying the exact chain, address, range, label, and canonical ABI is idempotent; any other overlapping inclusive range is rejected.

  • Use separate non-overlapping ranges for proxy upgrades. Adjacent ranges must end at N and begin at N + 1.
  • Mutation is isolated to the database where this function is called.