# eth_getLogs

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://linea-mainnet.g.alchemy.com/v2/{apiKey}

Returns an array of all logs matching the specified filter.
### Supported Block Ranges
Here are the block ranges you're able to submit in a single query, depending on your plan tier:

> ⚠️ Note: All responses will be capped at 150MB.

| Chain | Free | Pay As You Go | Enterprise |
|-------|------|---------------|------------|
| Ethereum, Base, Optimism, Arbitrum, Worldchain, zkSync | 10 | unlimited | unlimited |
| Polygon | 10 | 2000 | unlimited |
| BSC, Unichain | 10 | 10,000 | 10,000 |
| Berachain | 10 | 1,000 | 100,000 |
| Plasma | 10 | 10,000 | 100,000 |
| Monad | 10 | 1000 | 1000 |
| Polygon zkEVM | 10 | 10,000 | 20,000 |
| Sei | 10 | 2000 | 2000 |
| All Other Chains | 10 | 10,000 | 10,000*** |

*** Note: Querying block ranges wider than 10k for these chains is possible but less likely to succeed. Try splitting large queries into smaller parts to boost performance and reduce the likelihood of failure.


Reference: https://www.alchemy.com/docs/chains/linea/linea-api-endpoints/eth-get-logs

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Filter | object | Yes | The filter options object to specify the criteria for logs retrieval. |

## Result

**Log objects** (string[] or object[]): An array of log objects matching the filter criteria.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x137d3c2",
      "toBlock": "0x137d3c3",
      "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "topics": []
    }
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": [
    {
      "logIndex": "0x0",
      "removed": false,
      "blockNumber": "0x233",
      "blockHash": "0xfc139f5e2edee9e9c888d8df9a2d2226133a9bd87c88ccbd9c930d3d4c9f9ef5",
      "transactionHash": "0x66e7a140c8fa27fe98fde923defea7562c3ca2d6bb89798aabec65782c08f63d",
      "transactionIndex": "0x0",
      "address": "0x42699a7612a82f1d9c36148af9c77354759b210b",
      "data": "0x0000000000000000000000000000000000000000000000000000000000000004",
      "topics": [
        "0x04474795f5b996ff80cb47c148d4c5ccdbe09ef27551820caa9c2f8ed149cce3"
      ]
    },
    {
      "logIndex": "0x0",
      "removed": false,
      "blockNumber": "0x238",
      "blockHash": "0x98b0ec0f9fea0018a644959accbe69cd046a8582e89402e1ab0ada91cad644ed",
      "transactionHash": "0xdb17aa1c2ce609132f599155d384c0bc5334c988a6c368056d7e167e23eee058",
      "transactionIndex": "0x0",
      "address": "0x42699a7612a82f1d9c36148af9c77354759b210b",
      "data": "0x0000000000000000000000000000000000000000000000000000000000000007",
      "topics": [
        "0x04474795f5b996ff80cb47c148d4c5ccdbe09ef27551820caa9c2f8ed149cce3"
      ]
    }
  ],
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://linea-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x137d3c2",
      "toBlock": "0x137d3c3",
      "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "topics": []
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'eth_getLogs',
    params: [
      {
        fromBlock: '0x137d3c2',
        toBlock: '0x137d3c3',
        address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
        topics: []
      }
    ]
  })
};

fetch('https://linea-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://linea-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_getLogs",
    "params": [
        {
            "fromBlock": "0x137d3c2",
            "toBlock": "0x137d3c3",
            "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
            "topics": []
        }
    ]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://linea-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getLogs\",\n  \"params\": [\n    {\n      \"fromBlock\": \"0x137d3c2\",\n      \"toBlock\": \"0x137d3c3\",\n      \"address\": \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n      \"topics\": []\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://linea-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getLogs\",\n  \"params\": [\n    {\n      \"fromBlock\": \"0x137d3c2\",\n      \"toBlock\": \"0x137d3c3\",\n      \"address\": \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n      \"topics\": []\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://linea-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getLogs\",\n  \"params\": [\n    {\n      \"fromBlock\": \"0x137d3c2\",\n      \"toBlock\": \"0x137d3c3\",\n      \"address\": \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n      \"topics\": []\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: eth_getLogs
summary: Returns an array of all logs matching the specified filter.
description: |
  Returns an array of all logs matching the specified filter.
  ### Supported Block Ranges
  Here are the block ranges you're able to submit in a single query, depending on your plan tier:

  > ⚠️ Note: All responses will be capped at 150MB.

  | Chain | Free | Pay As You Go | Enterprise |
  |-------|------|---------------|------------|
  | Ethereum, Base, Optimism, Arbitrum, Worldchain, zkSync | 10 | unlimited | unlimited |
  | Polygon | 10 | 2000 | unlimited |
  | BSC, Unichain | 10 | 10,000 | 10,000 |
  | Berachain | 10 | 1,000 | 100,000 |
  | Plasma | 10 | 10,000 | 100,000 |
  | Monad | 10 | 1000 | 1000 |
  | Polygon zkEVM | 10 | 10,000 | 20,000 |
  | Sei | 10 | 2000 | 2000 |
  | All Other Chains | 10 | 10,000 | 10,000*** |

  *** Note: Querying block ranges wider than 10k for these chains is possible but less likely to succeed. Try splitting large queries into smaller parts to boost performance and reduce the likelihood of failure.
params:
  - name: Filter
    required: true
    description: The filter options object to specify the criteria for logs retrieval.
    schema:
      title: filter
      type: object
      additionalProperties: false
      properties:
        fromBlock:
          title: from block
          oneOf:
            - title: Block number
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            - title: Block tag
              type: string
              enum:
                - earliest
                - finalized
                - safe
                - latest
                - pending
              description: '`earliest`: The lowest numbered block the client has available; `finalized`: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; `safe`: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; `latest`: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions; `pending`: A sample next block built by the client on top of `latest` and containing the set of transactions usually taken from local mempool. Before the merge transition is finalized, any call querying for `finalized` or `safe` block MUST be responded to with `-39001: Unknown block` error'
          description: Block number or tag to start searching from. Defaults to `latest`.
        toBlock:
          title: to block
          oneOf:
            - title: Block number
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            - title: Block tag
              type: string
              enum:
                - earliest
                - finalized
                - safe
                - latest
                - pending
              description: '`earliest`: The lowest numbered block the client has available; `finalized`: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; `safe`: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; `latest`: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions; `pending`: A sample next block built by the client on top of `latest` and containing the set of transactions usually taken from local mempool. Before the merge transition is finalized, any call querying for `finalized` or `safe` block MUST be responded to with `-39001: Unknown block` error'
          description: Block number or tag to end searching at. Defaults to `latest`.
        address:
          title: Address(es)
          oneOf:
            - title: Any Address
              type: 'null'
            - title: Address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            - title: Addresses
              type: array
              items:
                title: hex encoded address
                type: string
                pattern: ^0x[0-9a-fA-F]{40}$
        topics:
          title: Topics
          oneOf:
            - title: Any Topic Match
              type: 'null'
            - title: Specified Filter Topics
              type: array
              items:
                title: Filter Topic List Entry
                oneOf:
                  - title: Single Topic Match
                    type: string
                    pattern: ^0x[0-9a-f]{64}$
                  - title: Multiple Topic Match
                    type: array
                    items:
                      title: 32 hex encoded bytes
                      type: string
                      pattern: ^0x[0-9a-f]{64}$
result:
  name: Log objects
  description: An array of log objects matching the filter criteria.
  schema:
    title: Filter results
    oneOf:
      - title: new block or transaction hashes
        type: array
        items:
          title: 32 byte hex value
          type: string
          pattern: ^0x[0-9a-f]{64}$
      - title: new logs
        type: array
        items:
          title: log
          type: object
          required:
            - transactionHash
          additionalProperties: false
          properties:
            removed:
              title: removed
              type: boolean
            logIndex:
              title: log index
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            transactionIndex:
              title: transaction index
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            transactionHash:
              title: transaction hash
              type: string
              pattern: ^0x[0-9a-f]{64}$
            blockHash:
              title: block hash
              type: string
              pattern: ^0x[0-9a-f]{64}$
            blockNumber:
              title: block number
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            address:
              title: address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            data:
              title: data
              type: string
              pattern: ^0x[0-9a-f]*$
            topics:
              title: topics
              type: array
              items:
                title: 32 hex encoded bytes
                type: string
                pattern: ^0x[0-9a-f]{64}$
examples:
  - name: eth_getLogs example
    params:
      - name: Filter
        value:
          fromBlock: '0x137d3c2'
          toBlock: '0x137d3c3'
          address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
          topics: []
    result:
      name: Log objects
      value:
        - logIndex: '0x0'
          removed: false
          blockNumber: '0x233'
          blockHash: '0xfc139f5e2edee9e9c888d8df9a2d2226133a9bd87c88ccbd9c930d3d4c9f9ef5'
          transactionHash: '0x66e7a140c8fa27fe98fde923defea7562c3ca2d6bb89798aabec65782c08f63d'
          transactionIndex: '0x0'
          address: '0x42699a7612a82f1d9c36148af9c77354759b210b'
          data: '0x0000000000000000000000000000000000000000000000000000000000000004'
          topics:
            - '0x04474795f5b996ff80cb47c148d4c5ccdbe09ef27551820caa9c2f8ed149cce3'
        - logIndex: '0x0'
          removed: false
          blockNumber: '0x238'
          blockHash: '0x98b0ec0f9fea0018a644959accbe69cd046a8582e89402e1ab0ada91cad644ed'
          transactionHash: '0xdb17aa1c2ce609132f599155d384c0bc5334c988a6c368056d7e167e23eee058'
          transactionIndex: '0x0'
          address: '0x42699a7612a82f1d9c36148af9c77354759b210b'
          data: '0x0000000000000000000000000000000000000000000000000000000000000007'
          topics:
            - '0x04474795f5b996ff80cb47c148d4c5ccdbe09ef27551820caa9c2f8ed149cce3'
```
