---
title: "eth_getLogs"
description: "Returns logs matching a filter (Ethereum)"
url: "https://blockreq.com/docs/build/api-reference/ethereum/eth_getLogs/"
---

# eth_getLogs

**Network:** Ethereum · Mainnet · Chain ID `1` (`0x1`)

**Counts as 1 request.** See [Request Counting](https://blockreq.com/docs/pricing/request-counting/index.md).

Returns an array of all logs matching a given filter object. This is one of the most commonly used methods for indexing and monitoring smart contract events.

## Parameters

1. `Object` — Filter options:
   | Field | Type | Description |
   |-------|------|-------------|
   | fromBlock | QUANTITY\|TAG | Start block (default: `"latest"`) |
   | toBlock | QUANTITY\|TAG | End block (default: `"latest"`) |
   | address | DATA\|Array | Contract address(es) to filter |
   | topics | Array | Topic filters (indexed event params) |
   | blockHash | DATA | Restricts to a single block |

## Returns

`Array` — Array of log objects:

| Field           | Type          | Description                   |
| --------------- | ------------- | ----------------------------- |
| address         | DATA          | Contract that emitted the log |
| topics          | `Array<DATA>` | Indexed event parameters      |
| data            | DATA          | Non-indexed event parameters  |
| blockNumber     | QUANTITY      | Block number                  |
| transactionHash | DATA          | Transaction hash              |
| logIndex        | QUANTITY      | Log index in block            |

## Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x134E800",
      "toBlock": "0x134E810",
      "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }
  ],
  "id": 1
}
```

The example filters ERC-20 `Transfer` events for one token contract. Replace `address` and the block range with values on Ethereum.

> The topic `0xddf252ad...` is the keccak-256 hash of `Transfer(address,address,uint256)`.

## Code Examples

**cURL**

```bash
curl -X POST https://ethereum-rpc.blockreq.com/v1/rpc/public \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock":"0x134E800","toBlock":"0x134E810","address":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}],"id":1}'
```

**TypeScript**

```typescript
const response = await fetch("https://ethereum-rpc.blockreq.com/v1/rpc/public", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "jsonrpc": "2.0",
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x134E800",
      "toBlock": "0x134E810",
      "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
      ]
    }
  ],
  "id": 1
}),
});
const data = await response.json();
console.log(data.result);
```

**Python**

```python
import requests

response = requests.post(
    "https://ethereum-rpc.blockreq.com/v1/rpc/public",
    json={
  "jsonrpc": "2.0",
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x134E800",
      "toBlock": "0x134E810",
      "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
      ]
    }
  ],
  "id": 1
}
)
print(response.json()["result"])
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	payload := []byte(`{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock":"0x134E800","toBlock":"0x134E810","address":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}],"id":1}`)
	resp, err := http.Post(
		"https://ethereum-rpc.blockreq.com/v1/rpc/public",
		"application/json",
		bytes.NewBuffer(payload),
	)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	var result map[string]interface{}
	json.Unmarshal(body, &result)
	fmt.Println(result["result"])
}
```

**viem**

```typescript
import { createPublicClient, http } from "viem";

const client = createPublicClient({
  transport: http("https://ethereum-rpc.blockreq.com/v1/rpc/public"),
});

const result = await client.request({
  method: "eth_getLogs",
  params: [{"fromBlock":"0x134E800","toBlock":"0x134E810","address":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}],
});
console.log(result);
```

**Foundry**

```bash
cast rpc --rpc-url https://ethereum-rpc.blockreq.com/v1/rpc/public eth_getLogs {"fromBlock":"0x134E800","toBlock":"0x134E810","address":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}
```

**Hardhat**

```javascript
const { ethers } = require("hardhat");

async function main() {
  const provider = new ethers.JsonRpcProvider("https://ethereum-rpc.blockreq.com/v1/rpc/public");
  const result = await provider.send("eth_getLogs", [{"fromBlock":"0x134E800","toBlock":"0x134E810","address":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}]);
  console.log(result);
}

main();
```
