🦆
BlockDuck
  • BlockDuck
    • Introduce
    • Why BlockDuck
  • Getting Started
    • Quickstart
    • How to build
    • Try your first query
    • Supported Blockchains
  • Functionality
    • Basic EVM structure table function
      • Blocks
      • Transactions
      • Logs
      • Traces
      • Traces v2
      • Latest Block Number
    • Customized EVM contact table function
      • Contract Events
      • Contract view function
    • Bitcoin table function
      • Blocks
      • Transactions
      • Outputs
      • Inputs
    • Parameter Setting
      • Verbose logging
      • Configs setting
  • Types
    • Types Mapping between DuckDB and EVM
  • Examples
    • Python examples
      • Hourly ERC20 transfer volumn monitor page
Powered by GitBook
On this page
  • Table function
  • Procedure
  • Inputs
  • Outputs
  • Example
  • Dependent RPC Method
  1. Functionality
  2. Basic EVM structure table function

Logs

Table function

Logs are generated by the EVM during smart contract execution. They capture events that occur, providing a way to store data on the blockchain. Each log is composed of:

  • Data: Non-indexed data.

  • Topic List: A list containing 0 to 4 topics, each 32 bytes. Topic0 contains the hash of the event's signature (indexed), while the remaining topics are indexed parameters.

The eth_logs_rpc table represents these logs, making event data accessible and organized for users and applications.

Procedure

To utilize the eth_logs_rpc function, follow these steps:

  1. Connect to an Ethereum Node: Ensure you have access to an Ethereum node via its URL. This will be used as the url parameter in the function.

  2. Identify the Contract Address: Collect the contract addresses of interest, which will be used as the address parameter. These should be specified in a list format.

  3. Define the Relevant Topics: Determine the topics you wish to filter logs by. This includes the event signature hash and any other indexed parameters as a list under the topics argument.

  4. Specify the Block Range: Decide the block range for the log search. Set the fromBlock and toBlock to define the starting and ending block numbers, respectively.

  5. Call the Function: Execute the eth_logs_rpc function with the specified parameters to retrieve the logs.

  6. Process the Retrieved Data: Use the output columns to analyze the data, focusing on relevant information such as the transaction hash, block details, and specific event data.

Inputs

Args
Types
Info

address

LIST(VARCHAR)

Contract address emitting the log

topics

LIST(VARCHAR)

List of topics of the log

fromBlock

BIGINT

Block number to start scanning from

toBlock

BIGINT

Block number to stop scanning at

url

VARCHAR

URL of the Ethereum node

Outputs

Column Name
Type
Description

address

VARCHAR

Contract address emitting the log

blockHash

VARCHAR

Hash of the block containing the log

blockNumber

BIGINT

Number of the block containing the log

data

VARCHAR

Event-specific data (e.g., amount transferred)

logIndex

INTEGER

Log's position within the block

removed

BOOLEAN

Indicates if log was removed in chain reorganization

topics

LIST(VARCHAR)

Indexed event parameters (event signature, addresses)

transactionHash

VARCHAR

Hash of the transaction generating the log

transactionIndex

INTEGER

Transaction's position within the block

Example

D set variable eth_url = 'https://eth-mainnet.g.alchemy.com/v2/{API_KEY}';
D select * from eth_logs_rpc([]::VARCHAR[], []::VARCHAR[], 21104078, 21104089, getvariable('eth_url')) limit 10;
┌──────────────────────┬──────────────────────┬─────────────┬──────────────────────┬──────────┬─────────┬──────────────────────┬───────────────────────────────────────────────────┬──────────────────┐
│       address        │      blockHash       │ blockNumber │         data         │ logIndex │ removed │        topics        │                  transactionHash                  │ transactionIndex │
│       varchar        │       varchar        │    int64    │       varchar        │  int32   │ boolean │      varchar[]       │                      varchar                      │      int32       │
├──────────────────────┼──────────────────────┼─────────────┼──────────────────────┼──────────┼─────────┼──────────────────────┼───────────────────────────────────────────────────┼──────────────────┤
│ 0xabec00542d141bdd…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0x0000000000000000…  │        0 │ false   │ [0xddf252ad1be2c89…  │ 0x15b539fdf722615ab60cc7885f2d2fb13c0d14a4651dd…  │                0 │
│ 0xabec00542d141bdd…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0x0000000000000000…  │        1 │ false   │ [0xddf252ad1be2c89…  │ 0x15b539fdf722615ab60cc7885f2d2fb13c0d14a4651dd…  │                0 │
│ 0xc02aaa39b223fe8d…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0x0000000000000000…  │        2 │ false   │ [0xddf252ad1be2c89…  │ 0x15b539fdf722615ab60cc7885f2d2fb13c0d14a4651dd…  │                0 │
│ 0xabd055069a6b04db…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0xffffffffffffffff…  │        3 │ false   │ [0xc42079f94a6350d…  │ 0x15b539fdf722615ab60cc7885f2d2fb13c0d14a4651dd…  │                0 │
│ 0xc02aaa39b223fe8d…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0x0000000000000000…  │        4 │ false   │ [0xddf252ad1be2c89…  │ 0x15b539fdf722615ab60cc7885f2d2fb13c0d14a4651dd…  │                0 │
│ 0x60a8ea6005f7db58…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0x0000000000000000…  │        5 │ false   │ [0x1c411e9a96e0712…  │ 0x15b539fdf722615ab60cc7885f2d2fb13c0d14a4651dd…  │                0 │
│ 0x60a8ea6005f7db58…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0x0000000000000000…  │        6 │ false   │ [0xd78ad95fa46c994…  │ 0x15b539fdf722615ab60cc7885f2d2fb13c0d14a4651dd…  │                0 │
│ 0x000000000022d473…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0x0000000000000000…  │        7 │ false   │ [0xc6a377bfc4eb120…  │ 0x1bd4d5006a6b321cf7321a58bf48dd18653e87158d398…  │                1 │
│ 0xabec00542d141bdd…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0x0000000000000000…  │        8 │ false   │ [0xddf252ad1be2c89…  │ 0x1bd4d5006a6b321cf7321a58bf48dd18653e87158d398…  │                1 │
│ 0xabec00542d141bdd…  │ 0x8e8d1d95a717a152…  │    21104078 │ 0x0000000000000000…  │        9 │ false   │ [0xddf252ad1be2c89…  │ 0x1bd4d5006a6b321cf7321a58bf48dd18653e87158d398…  │                1 │
├──────────────────────┴──────────────────────┴─────────────┴──────────────────────┴──────────┴─────────┴──────────────────────┴───────────────────────────────────────────────────┴──────────────────┤
│ 10 rows                                                                                                                                                                                   9 columns │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Dependent RPC Method

  • eth_getLogs

PreviousTransactionsNextTraces

Last updated 4 months ago