Loading

get_logs

Table function

Streams contract logs via eth_getLogs, decoding topics with human-readable signatures or ABI. Named parameters for topic filtering (available on all overloads): - topic1 := BYTES32 or BYTES32[] - Filter first indexed parameter (exact match or OR) - topic2 := BYTES32 or BYTES32[] - Filter second indexed parameter - topic3 := BYTES32 or BYTES32[] - Filter third indexed parameter For Transfer events: topic1=from, topic2=to. Use NULL::ADDRESS to match all contracts.

get_logs(TRANSPORT, ADDRESS, VARCHAR)

Accepts a human-readable event signature (e.g. `event Transfer(...)`) and returns decoded fields.

Parameters

Name Type
transport TRANSPORT
address ADDRESS
event_signature VARCHAR

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
-- Basic usage
2
SELECT *
3
FROM get_logs(
4
$transport,
5
'0x4200000000000000000000000000000000000006'::ADDRESS,
6
'event Transfer(address indexed from, address indexed to, uint256 value)'
7
)
8
LIMIT 5;
9
 
10
-- With topic filter (transfers TO a specific address)
11
SELECT *
12
FROM get_logs(
13
$transport,
14
NULL::ADDRESS, -- match all contracts
15
'event Transfer(address indexed from, address indexed to, uint256 value)',
16
21350000, 21351000,
17
topic2 := '0x000000000000000000000000d8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::BYTES32
18
);
19
 
20
-- With OR filter (transfers TO addr1 OR addr2)
21
SELECT *
22
FROM get_logs(
23
$transport,
24
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'::ADDRESS,
25
'event Transfer(address indexed from, address indexed to, uint256 value)',
26
21350000, 21350100,
27
topic2 := ['0x000...addr1', '0x000...addr2']::BYTES32[]
28
);
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS, JSON)

Accepts a JSON ABI fragment to drive indexed/non-indexed decoding.

Parameters

Name Type
transport TRANSPORT
address ADDRESS
event_abi JSON

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport, -- transport
4
'0x4200000000000000000000000000000000000006'::address, -- Base WETH
5
json('{"type":"event","name":"Transfer","inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}]}') -- event_abi
6
)
7
LIMIT 5;
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS, VARCHAR, BIGINT)

Adds an inclusive starting block height to constrain the log window.

Parameters

Name Type
transport TRANSPORT
address ADDRESS
event_signature VARCHAR
from_block BIGINT

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport, -- transport
4
'0x4200000000000000000000000000000000000006'::address, -- Base WETH
5
'event Transfer(address indexed from, address indexed to, uint256 value)', -- event_signature
6
36760640 -- from_block
7
);
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS, JSON, BIGINT)

JSON ABI flavour with a starting block filter for deterministic backfills.

Parameters

Name Type
transport TRANSPORT
address ADDRESS
event_abi JSON
from_block BIGINT

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport, -- transport
4
'0x4200000000000000000000000000000000000006'::address, -- Base WETH
5
json('{"type":"event","name":"Transfer","inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}]}'), -- event_abi
6
36760640 -- from_block
7
);
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS, VARCHAR, BIGINT, BIGINT)

Specifies both start and end block heights (inclusive) for bounded range scans.

Parameters

Name Type
transport TRANSPORT
address ADDRESS
event_signature VARCHAR
from_block BIGINT
to_block BIGINT

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport, -- transport
4
'0x4200000000000000000000000000000000000006'::address, -- Base WETH
5
'event Transfer(address indexed from, address indexed to, uint256 value)', -- event_signature
6
36760640, -- from_block
7
36760643 -- to_block
8
);
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS, JSON, BIGINT, BIGINT)

JSON ABI variant that constrains the log search window with explicit from/to heights.

Parameters

Name Type
transport TRANSPORT
address ADDRESS
event_abi JSON
from_block BIGINT
to_block BIGINT

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport, -- transport
4
'0x4200000000000000000000000000000000000006'::address, -- Base WETH
5
json('{"type":"event","name":"Transfer","inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}]}'), -- event_abi
6
36760640, -- from_block
7
36760643 -- to_block
8
);
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS[], VARCHAR)

Query logs from multiple contract addresses in a single call. Addresses are batched (max 50 per RPC request).

Parameters

Name Type
transport TRANSPORT
addresses ADDRESS[]
event_signature VARCHAR

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport,
4
['0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
5
'0xdAC17F958D2ee523a2206206994597C13D831ec7']::ADDRESS[], -- USDC + USDT
6
'event Transfer(address indexed from, address indexed to, uint256 value)'
7
)
8
LIMIT 10;
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS[], JSON)

JSON ABI variant for querying multiple addresses.

Parameters

Name Type
transport TRANSPORT
addresses ADDRESS[]
event_abi JSON

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport,
4
['0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48']::ADDRESS[],
5
json('{"type":"event","name":"Transfer","inputs":[...]}')
6
)
7
LIMIT 10;
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS[], VARCHAR, BIGINT)

Query logs from multiple addresses with a starting block constraint.

Parameters

Name Type
transport TRANSPORT
addresses ADDRESS[]
event_signature VARCHAR
from_block BIGINT

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport,
4
['0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
5
'0xdAC17F958D2ee523a2206206994597C13D831ec7']::ADDRESS[],
6
'event Transfer(address indexed from, address indexed to, uint256 value)',
7
21350000
8
);
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS[], JSON, BIGINT)

JSON ABI variant for querying multiple addresses with a starting block.

Parameters

Name Type
transport TRANSPORT
addresses ADDRESS[]
event_abi JSON
from_block BIGINT

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport,
4
['0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48']::ADDRESS[],
5
json('{"type":"event","name":"Transfer","inputs":[...]}'),
6
21350000
7
);
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS[], VARCHAR, BIGINT, BIGINT)

Query logs from multiple contract addresses with explicit block range. Addresses are batched (max 50 per RPC request).

Parameters

Name Type
transport TRANSPORT
addresses ADDRESS[]
event_signature VARCHAR
from_block BIGINT
to_block BIGINT

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport,
4
['0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
5
'0xdAC17F958D2ee523a2206206994597C13D831ec7']::ADDRESS[], -- USDC + USDT
6
'event Transfer(address indexed from, address indexed to, uint256 value)',
7
21350000,
8
21350100
9
);
Notebook ready in readonly mode.

get_logs(TRANSPORT, ADDRESS[], JSON, BIGINT, BIGINT)

JSON ABI variant for querying multiple addresses with explicit block range.

Parameters

Name Type
transport TRANSPORT
addresses ADDRESS[]
event_abi JSON
from_block BIGINT
to_block BIGINT

Result columns

Name Type
address ADDRESS
block_hash BYTES32
block_number BLOCK_NUMBER
transaction_hash BYTES32
transaction_index INTEGER
log_index INTEGER
data BLOB
removed BOOLEAN
topics BYTES32[]
... ABI-dependent column(s)
1
SELECT *
2
FROM get_logs(
3
$transport,
4
['0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48']::ADDRESS[],
5
json('{"type":"event","name":"Transfer","inputs":[...]}'),
6
21350000,
7
21350100
8
);
Notebook ready in readonly mode.