---
title: "eth_newFilter"
description: "The eth_newFilter method creates a filter object based on the given filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges."
order: 135
---

# eth_newFilter

## Overview

The **'eth_newFilter'** method creates a filter object based on the given filter options, to notify when the state changes (logs). To check if the state has changed, call **'eth_getFilterChanges'**.

**'*Duration*'**:

Filter IDs will be valid for up to fifteen minutes and can be polled by any connection using the same YOUR-COINAPI-KEY.

## Request

### shell

```shell
curl --request POST \
  --url https://ethereum-mainnet-geth-archive.node.coinapi.io \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --header 'X-CoinAPI-Key: abk_3f2504e04f8941d39a0c0305e82c3301582005f7' \
  --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_newFilter",
  "params": [
    {
      "address": [
        "0xb59f67a8bff5d8cd03f6ac17265c550ed8f33907"
      ],
      "fromBlock": "0x429d3b",
      "toBlock": "latest",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
        "0x00000000000000000000000000b46c2526e227482e2ebb8f4c69e4674d262e75",
        "0x00000000000000000000000054a2d42a40f51259dedd1978f6c118a0f0eff078"
      ]
    }
  ]
}'
```


### csharp

```csharp
using RestSharp; {

var options = new RestClientOptions("https://ethereum-mainnet-geth-archive.node.coinapi.io");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json","X-CoinAPI-Key: abk_3f2504e04f8941d39a0c0305e82c3301582005f7");
request.AddJsonBody("{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"eth_newFilter\",\"params\":[{\"address\":[\"0xb59f67a8bff5d8cd03f6ac17265c550ed8f33907\"],\"fromBlock\":\"0x429d3b\",\"toBlock\":\"latest\",\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x00000000000000000000000000b46c2526e227482e2ebb8f4c69e4674d262e75\",\"0x00000000000000000000000054a2d42a40f51259dedd1978f6c118a0f0eff078\"]}]}", false);
var response = await client.PostAsync(request);

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


### php

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://ethereum-mainnet-geth-archive.node.coinapi.io",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 1,
'jsonrpc' => '2.0',
'method' => 'eth_newFilter',
'params' => [
[
'address' => [
'0xb59f67a8bff5d8cd03f6ac17265c550ed8f33907'
],
'fromBlock' => '0x429d3b',
'toBlock' => 'latest',
'topics' => [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x00000000000000000000000000b46c2526e227482e2ebb8f4c69e4674d262e75',
'0x00000000000000000000000054a2d42a40f51259dedd1978f6c118a0f0eff078'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"content-type: application/json",
"X-CoinAPI-Key": "abk_3f2504e04f8941d39a0c0305e82c3301582005f7"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
    ?>
```


### python

```python
import requests

url = "https://ethereum-mainnet-geth-archive.node.coinapi.io"

payload = {
    "id": 1,
    "jsonrpc": "2.0",
    "method": "eth_newFilter",
    "params": [
        {
            "address": ["0xb59f67a8bff5d8cd03f6ac17265c550ed8f33907"],
            "fromBlock": "0x429d3b",
            "toBlock": "latest",
            "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x00000000000000000000000000b46c2526e227482e2ebb8f4c69e4674d262e75", "0x00000000000000000000000054a2d42a40f51259dedd1978f6c118a0f0eff078"]
        }
    ]
}
headers = {
    "accept": "application/json",
    "content-type": "application/json"
    "X-CoinAPI-Key" : "abk_3f2504e04f8941d39a0c0305e82c3301582005f7"
}

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

print(response.text)
```


### javascript

```javascript copy
    const options = {
  method: 'POST',
  headers: {accept: 'application/json', 'content-type': 'application/json', 'X-CoinAPI-Key': 'abk_3f2504e04f8941d39a0c0305e82c3301582005f7'},
  body: JSON.stringify({
    id: 1,
    jsonrpc: '2.0',
    method: 'eth_newFilter',
    params: [
      {
        address: ['0xb59f67a8bff5d8cd03f6ac17265c550ed8f33907'],
        fromBlock: '0x429d3b',
        toBlock: 'latest',
        topics: [
          '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
          '0x00000000000000000000000000b46c2526e227482e2ebb8f4c69e4674d262e75',
          '0x00000000000000000000000054a2d42a40f51259dedd1978f6c118a0f0eff078'
        ]
      }
    ]
  })
};

fetch('https://ethereum-mainnet-geth-archive.node.coinapi.io', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
```


### go

```go
package main

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

func main() {

	url := "https://ethereum-mainnet-geth-archive.node.coinapi.io"

	payload := strings.NewReader("{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"eth_newFilter\",\"params\":[{\"address\":[\"0xb59f67a8bff5d8cd03f6ac17265c550ed8f33907\"],\"fromBlock\":\"0x429d3b\",\"toBlock\":\"latest\",\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x00000000000000000000000000b46c2526e227482e2ebb8f4c69e4674d262e75\",\"0x00000000000000000000000054a2d42a40f51259dedd1978f6c118a0f0eff078\"]}]}")

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

	req.Header.Add("accept", "application/json")
	req.Header.Add("content-type", "application/json")
  req.Header.Add("X-CoinAPI-Key", "abk_3f2504e04f8941d39a0c0305e82c3301582005f7")


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

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

	fmt.Println(string(body))

}
```


### ruby

```ruby
require 'uri'
require 'net/http'

url = URI("https://ethereum-mainnet-geth-archive.node.coinapi.io")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request["X-CoinAPI-Key"] = 'abk_3f2504e04f8941d39a0c0305e82c3301582005f7'
request.body = "{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"eth_newFilter\",\"params\":[{\"address\":[\"0xb59f67a8bff5d8cd03f6ac17265c550ed8f33907\"],\"fromBlock\":\"0x429d3b\",\"toBlock\":\"latest\",\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x00000000000000000000000000b46c2526e227482e2ebb8f4c69e4674d262e75\",\"0x00000000000000000000000054a2d42a40f51259dedd1978f6c118a0f0eff078\"]}]}"

response = http.request(request)
puts response.read_body
```


### java

```java
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"eth_newFilter\",\"params\":[{\"address\":[\"0xb59f67a8bff5d8cd03f6ac17265c550ed8f33907\"],\"fromBlock\":\"0x429d3b\",\"toBlock\":\"latest\",\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x00000000000000000000000000b46c2526e227482e2ebb8f4c69e4674d262e75\",\"0x00000000000000000000000054a2d42a40f51259dedd1978f6c118a0f0eff078\"]}]}");
Request request = new Request.Builder()
  .url("https://ethereum-mainnet-geth-archive.node.coinapi.io")
  .post(body)
  .addHeader("accept", "application/json")
  .addHeader("content-type", "application/json")
  .addHeader("X-CoinAPI-Key", "abk_3f2504e04f8941d39a0c0305e82c3301582005f7")
  .build();

Response response = client.newCall(request).execute();
```


## Request Parameters

A filter object with the following keys and their values:

- **'address'**: [optional] A contract address or a list of addresses from which logs should originate.
- **fromBlock'**: [optional, default is latest] A hexadecimal block number, or the string latest, earliest, or pending. See the default block parameter.
- **'toBlock'**: [optional, default is latest] A hexadecimal block number, or the string latest, earliest, or pending. See the default block parameter.
- **'topics'**: [optional] An array of 32 bytes DATA topics. Topics are order-dependent.

## Topic Filters:

Topics are order-dependent. A transaction with a log with topics **'[A, B]'** will be matched by the following topic filters:

- **'[]'**: Anything.
- **'[A]'**: **'A'** in the first position, and anything after.
- **'[null, B]'**: Anything in the first position AND **'B'** in the second position, and anything after.
- **'[A, B]'**: **'A'** in the first position AND **'B'** in the second position, and anything after.
- **'[[A, B], [A, B]]'**: **'(A OR B)'** in the first position AND **'(A OR B)'** in the second position, and anything after.

## Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x7da018f96a3cd71bef5eedd3fc66596e"
}
```

- **filter ID**: A hexadecimal denoting the newly created filter ID.