Skip to content

Commit

Permalink
Added private filters concept content (#373)
Browse files Browse the repository at this point in the history
* Added private filters

Signed-off-by: Madeline Murray <[email protected]>
  • Loading branch information
MadelineMurray authored May 20, 2020
1 parent fe18626 commit 9b44980
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions docs/HowTo/Interact/Filters/Accessing-Logs-Using-JSON-RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Use [`eth_newFilter`](../../../Reference/API-Methods.md#eth_newfilter) to create
using [`eth_getFilterChanges`](../../../Reference/API-Methods.md#eth_getfilterchanges) and
[`eth_getFilterLogs`](../../../Reference/API-Methods.md#eth_getfilterlogs)).

Access logs for [private contracts](../../../Concepts/Privacy/Privacy-Overview.md) using the equivalent
[`priv_*` methods and specifying the privacy group ID](#filters-for-private-contracts). For example,
[`priv_getLogs`](../../../Reference/API-Methods.md#priv_getlogs).

!!! note

The sample contract included in [Events and Logs](../../../Concepts/Events-and-Logs.md) created
Expand Down Expand Up @@ -54,7 +58,7 @@ Create a filter using [`eth_newFilter`](../../../Reference/API-Methods.md#eth_ne
[`eth_newFilter`](../../../Reference/API-Methods.md#eth_newfilter) returns a filter ID hash (for
example, `0x1ddf0c00989044e9b41cc0ae40272df3`).

### Polling a Filter for changes
### Polling a filter for changes

To poll the filter for changes since the last poll, use
[`eth_getFilterChanges`](../../../Reference/API-Methods.md#eth_getfilterchanges) with the filter ID
Expand Down Expand Up @@ -150,10 +154,43 @@ When a filter is no longer required, use
[`eth_uninstallFilter`](../../../Reference/API-Methods.md#eth_uninstallfilter) to remove the
filter.

## Filters for private contracts

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

* [`priv_getFilterChanges`](../../../Reference/API-Methods.md#priv_getfilterchanges)
* [`priv_getFilterLogs`](../../../Reference/API-Methods.md#priv_getfilterlogs)
* [`priv_getLogs`](../../../Reference/API-Methods.md#priv_getlogs)
* [`priv_newFilter`](../../../Reference/API-Methods.md#priv_newfilter)
* [`priv_uninstallFilter`](../../../Reference/API-Methods.md#priv_uninstallfilter).

The [privacy group ID](../../../Concepts/Privacy/Privacy-Overview.md) must be specified as parameter 0
for the `priv` methods.

!!! example

```
{
"jsonrpc": "2.0",
"method": "priv_newFilter",
"params": [
"4rFldHM792LeP/e2WPkTXZedjwKuTr/KwCFTt6mBbkI=",
{
"fromBlock": "earliest",
"toBlock": "latest",
"addresses": ["0x991cc548c154b2953cc48c02f782e1314097dfbb"],
"topics": ["0x85bea11d86cefb165374e0f727bacf21dc2f4ea816493981ecf72dcfb212a410"]
}
],
"id": 1
}
```

## Getting logs using a filter options object

To get all logs for a filter options object, use
[`eth_getLogs`](../../../Reference/API-Methods.md#eth_getlogs).
[`eth_getLogs`](../../../Reference/API-Methods.md#eth_getlogs) or [`priv_getLogs`](../../../Reference/API-Methods.md#priv_getlogs)
for a private contract.

!!! example

Expand Down

0 comments on commit 9b44980

Please sign in to comment.