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:
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.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.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.Specify the Block Range: Decide the block range for the log search. Set the
fromBlock
andtoBlock
to define the starting and ending block numbers, respectively.Call the Function: Execute the eth_logs_rpc function with the specified parameters to retrieve the logs.
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
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
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
Dependent RPC Method
eth_getLogs
Last updated