eth_getLogs
Retrieve and filter event logs emitted by smart contracts. Supports block range, contract address, and topic filters with pagination.
Instructions
Query event logs emitted by smart contracts with flexible filters. Supports pagination for large result sets.
Args:
fromBlock (string): Start block as hex (e.g., '0x10d4f') or tag ('latest', 'earliest', 'pending').
toBlock (string): End block as hex or tag.
address (string, optional): Contract address to filter logs from.
topics (array, optional): Array of 32-byte topic filters for indexed event parameters.
network (string, optional): Ethereum network to query. Defaults to 'mainnet'.
limit (integer, optional): Maximum logs to return (1-10000). Defaults to 1000.
offset (integer, optional): Number of logs to skip for pagination. Defaults to 0.
Returns:
Object with 'logs' array and 'pagination' metadata (total, count, offset, limit, has_more, next_offset).
Examples:
"Get all logs in block range": { "fromBlock": "0x10d4f", "toBlock": "0x10d50" }
"Filter by contract and topic": { "fromBlock": "latest", "toBlock": "latest", "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"] }
"Paginate results": { "fromBlock": "0x10d4f", "toBlock": "0x10d50", "limit": 100, "offset": 0 }
Errors:
InvalidParams: When block tags or address format is invalid.
InternalError: When query range is too large or Infura API fails.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fromBlock | Yes | The starting block number or block identifier. | |
| toBlock | Yes | The ending block number or block identifier. | |
| address | No | The address of the contract to filter logs. | |
| topics | No | An array of topics to filter logs. | |
| network | No | The Ethereum network to query, e.g., 'mainnet' or 'sepolia'. | mainnet |
| limit | No | Maximum number of logs to return (default: 1000, max: 10000). Use with offset for pagination. | |
| offset | No | Number of logs to skip for pagination (default: 0). | |
| response_format | No | Output format: 'json' for structured data, 'markdown' for human-readable. | json |