create_access_list

Builds an EIP-2930 access list for a transaction request. Each result row identifies an accessed account or storage slot and includes request status.

Example

Needs RPC · RPC required

1
WITH requests AS (
2
WITH erc20_abi AS (
3
SELECT '[{"type":"function","name":"balanceOf","inputs":[{"name":"account","type":"address"}],"outputs":[{"name":"balance","type":"uint256"}]}]'::JSON AS abi
4
)
5
SELECT
6
$client AS client,
7
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'::ADDRESS AS to_address,
8
encode_function_data(
9
abi,
10
'balanceOf',
11
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS
12
) AS data,
13
25433824::BIGINT AS block_number,
14
'usdc-balance'::VARCHAR AS source_id,
15
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS AS from_address,
16
0::UINT256 AS value,
17
NULL::UBIGINT AS gas,
18
NULL::BYTES32 AS block_hash,
19
'{"on_error":"row"}'::JSON AS options
20
FROM erc20_abi
21
),
22
access_rows AS (
23
SELECT source_id, source_kind, state_kind, address, slot, rpc_status
24
FROM create_access_list((SELECT * FROM requests))
25
)
26
SELECT source_id, source_kind, state_kind, address, slot, rpc_status
27
FROM access_rows
28
WHERE rpc_status = 'ok' AND state_kind IN ('code', 'storage')
29
ORDER BY state_kind, address, slot;
Notebook ready in readonly mode.

API reference

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

create_access_list(CLIENT, ADDRESS, BYTES, BIGINT) # RPC required

Builds one access list from the required transaction fields at an exact block height.

Inputs

Name Type Use
client CLIENT

Attached live CLIENT for the chain and block used for the access-list request.

required positional
to_address ADDRESS

Contract or account that receives the simulated transaction.

required positional
data BYTES

Transaction input bytes, usually produced by encode_function_data.

required positional
block_number BIGINT

Exact block height used to discover accessed accounts and storage slots.

required positional

Input relation columns

NameTypeDefault
clientCLIENT

Attached live client for eth_createAccessList. Required

to_addressADDRESS

Transaction target address. Required

dataBYTES

Transaction call data. Required

block_numberBIGINT

Block number for deterministic access-list discovery. Required

source_idVARCHAR

Stable caller-provided identifier for emitted rows. Optional

Showing fewer

One eth_createAccessList request per row. Optional columns may be omitted only from the trailing end.

Result columns

NameType
source_kindVARCHAR

Output row class: access_list_code, access_list_storage, or rpc_error.

source_idVARCHAR

Stable caller-provided source id, or a generated row id when omitted.

state_kindVARCHAR

State kind emitted for prefetch planning.

addressADDRESS

Account or contract address from the access list.

slotBYTES32

Storage slot for storage-key rows, or zero for code/account rows.

Showing fewer

Access-list state rows plus RPC status. Returns one row per discovered account or storage key. With on_error set to row, failed requests emit an rpc_error row instead of failing the query.

Guidance

Choose error and canonicality behavior

The options JSON accepts on_error, require_canonical, retry_by_block_number_on_blockhash_error, and rpc_batch_size.

  • on_error="throw" fails the query; on_error="row" emits an rpc_error row.
  • require_canonical defaults to true when block_hash is supplied.
  • retry_by_block_number_on_blockhash_error defaults to true and retries with the corresponding block number.
  • rpc_batch_size limits requests grouped into one provider batch.

Local SQL

1
SELECT '{"on_error":"row","require_canonical":true,"retry_by_block_number_on_blockhash_error":true,"rpc_batch_size":100}'::JSON AS options;
Notebook ready in readonly mode.

Additional overloads

create_access_list(CLIENT, ADDRESS, BYTES, BIGINT, JSON) # RPC required

Builds one access list and applies the supplied error, canonicality, fallback, and batching options.

Inputs

Name Type Use
client CLIENT

Attached live CLIENT for the chain and block used for the access-list request.

required positional
to_address ADDRESS

Contract or account that receives the simulated transaction.

required positional
data BYTES

Transaction input bytes, usually produced by encode_function_data.

required positional
block_number BIGINT

Exact block height used to discover accessed accounts and storage slots.

required positional
options JSON

Caller-provided identifier copied to every result row for this request.

required positional

Input relation columns

NameTypeDefault
clientCLIENT

Attached live client for eth_createAccessList. Required

to_addressADDRESS

Transaction target address. Required

dataBYTES

Transaction call data. Required

block_numberBIGINT

Block number for deterministic access-list discovery. Required

source_idVARCHAR

Stable caller-provided identifier for emitted rows. Optional

Showing fewer

One eth_createAccessList request per row. Optional columns may be omitted only from the trailing end.

Result columns

NameType
source_kindVARCHAR

Output row class: access_list_code, access_list_storage, or rpc_error.

source_idVARCHAR

Stable caller-provided source id, or a generated row id when omitted.

state_kindVARCHAR

State kind emitted for prefetch planning.

addressADDRESS

Account or contract address from the access list.

slotBYTES32

Storage slot for storage-key rows, or zero for code/account rows.

Showing fewer

Access-list state rows plus RPC status. Returns one row per discovered account or storage key. With on_error set to row, failed requests emit an rpc_error row instead of failing the query.

create_access_list(CLIENT, ADDRESS, BYTES, BIGINT, VARCHAR, ADDRESS, UINT256, UBIGINT, BYTES32, JSON) # RPC required

Accepts a relation with full transaction context and returns correlated access-list rows for every request.

Inputs

NameTypeUse
clientCLIENT

Attached live CLIENT for the chain and block used for the access-list request.

requiredpositional
to_addressADDRESS

Contract or account that receives the simulated transaction.

requiredpositional
dataBYTES

Transaction input bytes, usually produced by encode_function_data.

requiredpositional
block_numberBIGINT

Exact block height used to discover accessed accounts and storage slots.

requiredpositional
source_idVARCHAR

Caller-provided identifier copied to every result row for this request.

requiredpositional
Showing fewer

Input relation columns

NameTypeDefault
clientCLIENT

Attached live client for eth_createAccessList. Required

to_addressADDRESS

Transaction target address. Required

dataBYTES

Transaction call data. Required

block_numberBIGINT

Block number for deterministic access-list discovery. Required

source_idVARCHAR

Stable caller-provided identifier for emitted rows. Optional

Showing fewer

One eth_createAccessList request per row. Optional columns may be omitted only from the trailing end.

Result columns

NameType
source_kindVARCHAR

Output row class: access_list_code, access_list_storage, or rpc_error.

source_idVARCHAR

Stable caller-provided source id, or a generated row id when omitted.

state_kindVARCHAR

State kind emitted for prefetch planning.

addressADDRESS

Account or contract address from the access list.

slotBYTES32

Storage slot for storage-key rows, or zero for code/account rows.

Showing fewer

Access-list state rows plus RPC status. Returns one row per discovered account or storage key. With on_error set to row, failed requests emit an rpc_error row instead of failing the query.

Category and tags

Category
Chain reads
Tag
EVM
Tag
RPC
Tag
Prefetch