---
title: newFilter
slug: api/newfilter
createdAt: 2022-12-06T18:10:45.000Z
---

{
  "id": "pGthe4uXFzRDu1tEQd8tl",
  "data": {
    "url": "{{ENVIRONMENT}}",
    "method": "POST",
    "request": {
      "pathParameters": [],
      "queryParameters": [],
      "headerParameters": [
        {
          "name": "Content-Type",
          "type": "string",
          "example": "application/json",
          "description": ""
        }
      ],
      "bodyDataParameters": [
        {
          "name": "body",
          "type": "string",
          "example": "{\n\t\"jsonrpc\":\"2.0\",\n\t\"method\":\"eth_newFilter\",\n\t\"params\":[\n\t\t{\n\t\t\t\"topics\":[\"0x12341234\"]\n\t\t}\n\t],\n\t\"id\":73\n}",
          "description": ""
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "<p>Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call <code>eth_getFilterChanges</code>.</p>\n<p><strong>A note on specifying topic filters:</strong></p>\n<p>Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:</p>\n<p><code>[]</code> \"anything\"</p>\n<p><code>[A]</code> \"A in first position (and anything after)\"</p>\n<p><code>[null, B]</code> \"anything in first position AND B in second position (and anything after)\"</p>\n<p><code>[A, B]</code> \"A in first position AND B in second position (and anything after)\"</p>\n<p><code>[[A, B], [A, B]]</code> \"(A OR B) in first position AND (A OR B) in second position (and anything after)\"</p>\n<p><strong>Parameters</strong></p>\n<p><code>Object</code> - The filter options:</p>\n<p><code>fromBlock</code>: <code>QUANTITY|TAG</code> - (optional, default: <code>\"latest\"</code>) Integer block number, or <code>\"latest\"</code> for the last mined block or <code>\"pending\"</code>, <code>\"earliest\"</code> for not yet mined transactions.</p>\n<p><code>toBlock</code>: <code>QUANTITY|TAG</code> - (optional, default: <code>\"latest\"</code>) Integer block number, or <code>\"latest\"</code> for the last mined block or <code>\"pending\"</code>, <code>\"earliest\"</code> for not yet mined transactions.</p>\n<p><code>address</code>: <code>DATA|Array</code>, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.</p>\n<p><code>topics</code>: <code>Array of DATA</code>, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with \"or\" options.</p>\n<pre><code>params: [{\r\n  \"fromBlock\": \"0x1\",\r\n  \"toBlock\": \"0x2\",\r\n  \"address\": \" 0x8888f1f195afa192cfee860698584c030f4c9db1\",\r\n  \"topics\": [\"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b\", null, [\"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b\", \"0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc\"]]\r\n}]\n</code></pre>\n<p><strong>Returns</strong></p>\n<p><code>QUANTITY</code> - A filter id.</p>",
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url {{ENVIRONMENT}} \\\n     --header 'accept: application/json'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"{{ENVIRONMENT}}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"{{ENVIRONMENT}}\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"{{ENVIRONMENT}}\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": ""
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}