Access Logs

Accessing logs using the WoopChain API

Subscribe to events, such as logs, using either RPC Pub/Sub over WebSockets or filters over HTTP.

Access logs using the following WoopChain API methods:

Use eth_newFilter to create the filter before using eth_getFilterChanges and eth_getFilterLogs).

The following examples use the sample contract included in [events and logs](../../concepts/events-and-logs.md).

Create a filter

Create a filter using eth_newFilter.

!!! example

If the [example contract](../../concepts/events-and-logs.md) was deployed to
0x42699a7612a82f1d9c36148af9c77354759b210b, the following request for `eth_newFilter` creates a
filter to log when `valueIndexed` is set to 5:

```json
{
  "jsonrpc":"2.0",
  "method":"eth_newFilter",
  "params":[
    {
      "fromBlock":"earliest",
      "toBlock":"latest",
      "address":"0x42699a7612a82f1d9c36148af9c77354759b210b",
      "topics":[
        ["0xd3610b1c54575b7f4f0dc03d210b8ac55624ae007679b7a928a4f25a709331a8"],
        ["0x0000000000000000000000000000000000000000000000000000000000000005"]
      ]
    }
  ],
  "id":1
}
```

eth_newFilter returns a filter ID hash (for example, 0x1ddf0c00989044e9b41cc0ae40272df3).

Poll a filter for changes

To poll the filter for changes since the last poll, use eth_getFilterChanges with the filter ID hash returned by eth_newFilter.

!!! example

Get all logs for a filter

To get all logs for a filter, use eth_getFilterLogs.

!!! example

Uninstall a filter

When a filter is no longer required, use eth_uninstallFilter to remove the filter.

Filters for private contracts

Filters for private contracts are created, accessed, and uninstalled using:

Get logs using a filter options object

To get all logs for a filter options object, use eth_getLogs or priv_getLogs for a private contract.

!!! example

Last updated