eth_getLogs - Base Chain JSON-RPC Method
Overview
The eth_getLogs
method retrieves logs from the Base blockchain that match specified filter criteria. Logs are generated by smart contract events during transaction execution and provide valuable data about what occurred during transactions.
Parameters
-
Filter object
-
fromBlock
[optional, default is "latest"] - The block number or tag representing the start of the search range, hexadecimal encoded (or "latest", "earliest" or "pending") -
toBlock
[optional, default is "latest"] - The block number or tag representing the end of the search range, hexadecimal encoded (or "latest", "earliest" or "pending") -
address
[optional] - The contract address to filter for (or an array of addresses) -
topics
[optional] - Array of up to 4 32-byte data fields representing event topics. The first topic typically represents the event signature hash. Each topic can also be an array of 32-byte data fields to match multiple possibilities -
blockHash
[optional] - A specific block hash to search for logs. If present,fromBlock
andtoBlock
are ignored
-
Note: Unlike Ethereum and Arbitrum One chains, the "safe" and "finalized" tags are not available on Base chain.
Returns
-
Array of log objects
-
blockNumber
- Block number where the log was created (null for pending logs) -
blockHash
- Hash of the block where the log was created (null for pending logs) -
transactionHash
- Hash of the transaction that created the log (null for pending logs) -
transactionIndex
- Transaction's index position in the block -
address
- Address of the contract that generated the log -
topics
- Array of 0-4 indexed topics (32-byte values), first being the event signature -
data
- Contains the non-indexed parameters of the log -
logIndex
- Log's index position in the block (null for pending logs) -
removed
- Boolean indicating if the log was removed due to chain reorganization
-
Request
POST https://base-mainnet.chainnodes.org/YOUR-API-KEY
Need RPC API keys?
Get 12.5M archival requests for free today.
Example
- HTTPS POST Request with a JSON RPC call in the body
- Replace YOUR-API-KEY with the API key from your Chainnodes.org Dashboard
- You can use a different supported network by replacing
base-mainnet
curl https://base-mainnet.chainnodes.org/YOUR-API-KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getLogs","params": [{"fromBlock": "0x57f842", "toBlock": "0x57f842", "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}],"id":1}'
Body
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0x4200000000000000000000000000000000000006",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000f76ddbcef4c2c9c1612367fc5ce7d99bbfcfa200",
"0x00000000000000000000000085a2f0b4f60dcc11afb0df495863d9fa6a05288d"
],
"data": "0x0000000000000000000000000000000000000000000000000006b7a45ec41fc00",
"blockNumber": "0x57f842",
"transactionHash": "0x5e3e2a5af9d926eba3c308b8a12ef502bc0b1b3e38c65ccafbd22ea10edf6cb9",
"transactionIndex": "0x3",
"blockHash": "0x0d1cad6b75ab92cd1d1a9de1a2666ed25dc6a644d7e47daaa75949b5a9bf5e16",
"logIndex": "0x4",
"removed": false
}
]
}
💡 Confusing?
Ask our experienced blockchain developers in Telegram
Common Use Cases
-
Token Transfer Tracking
// Track ERC-20 token transfers (using Transfer event signature) {"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}
-
DEX Swap Monitoring
// Monitor swaps on a Base DEX (using Swap event signature) {"address": "0x1234...DEX_CONTRACT", "topics": ["0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822"]}
-
Contract Interaction History
// Get all events from a specific contract {"address": "0x4200000000000000000000000000000000000006"}
-
Historical Block Range Analysis
// Get all logs between two block heights {"fromBlock": "0x500000", "toBlock": "0x500100"}
-
Event Filtering By Sender/Receiver
// Filter ERC-20 transfers from a specific address (second topic is the sender) {"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x000000000000000000000000YOUR_ADDRESS_PADDED_TO_32_BYTES"]}
JSON-RPC Base APIs Documentation by CHAINNODES is based on Reth node client. Contact us if you are interested in specific methods that are only available on geth, besu, Nethermind or Erigon