Skip to content

docs: update webhook parameter filtering types and add example #7295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions apps/portal/src/app/insight/webhooks/filtering/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Each webhook must have either an events filter or a transactions filter (or both
signatures: { // Filter by event signatures
sig_hash: string, // Event signature hash
abi?: string, // Optional ABI for data decoding
params?: Record<string, any> // Filter on decoded parameters
params?: Record<string, string | number> // Filter on decoded parameters
}[]
}
}
Expand All @@ -51,7 +51,7 @@ Each webhook must have either an events filter or a transactions filter (or both
signatures: { // Filter by function signatures
sig_hash: string, // Function signature hash
abi?: string, // Optional ABI for data decoding
params?: string[] // Filter on decoded parameters
params?: Record<string, string | number> // Filter on decoded parameters
}[]
}
}
Expand Down Expand Up @@ -106,6 +106,27 @@ And this example will filter for `Approve` function calls on Ethereum for the co

`params` on the `signatures` object will allow you to filter based on the decoded data. Only strict equality is supported at the moment.

For example, if you want to filter for `Transfer` events where the `from` address is `0x1f9840a85d5af5bf1d1762f925bdaddc4201f984`, you can use the following:
```typescript
{
...
"filters": {
"v1.events": {
"chain_ids": ["1"],
"addresses": ["0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"],
"signatures": [{
"sig_hash": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"abi": "{\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}",
"params": {
"from": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"
}
}]
}
}
...
}
```

### Notes
- You can specify ABIs to receive decoded event/transaction data
- Parameter filtering supports equality matching only
Expand Down
Loading