Custom Webhook Variables
With GraphQL, Alchemy’s Custom Webhook is able to leverage the power of variables to dynamically insert values into a webhook query. In particular, users are able to filter data based on both addresses and log topics via Custom Webhook variables!
Variable Types
Custom Webhook variables can either be a set of addresses or bytes32 objects. This allows developers to either define variables for transaction level filters or logs!
Example Address Typed Variables
Variable Name:addressVariable
Variable Value: {0x5c43B1eD97e52d009611D89b74fA829FE4ac56b1, 0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5, 0x388C818CA8B9251b393131C08a736A67ccB19297 }
Address typed variables can be used in either [external transaction filters](External Transaction Filters) and/or internal transaction filters.
Example Log Topic Typed Variables
Variable Name:logTopicVariable
Variable Value: {0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c, 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822 }
Log Topic typed variables can be used in only event log filters!
Log Topic typed variables can represent an array of topic0, topic1, or topic2 elements.
How to Use Variables in Custom Webhooks
At the beginning of each GraphQL query where you want to use a variable, you must declare the variable!
query ($addressVariable: [Address!])
query ($addressVariable: [Address!], $logTopicVariable:[Bytes32!]!)
Examples Using A Variable:
Single Variable Custom Webhooks
In this example, we use a variable addressVar which is applied to an external transaction filter, specifically within the from address parameter.
Multi-Variable Custom Webhooks
In this example, we use 2 variables addressVar AND logTopic0 with the former being used in an external transaction filter and the former being applied to the event log filter.
FAQ
How many elements can I use within a Custom Webhook variable?
Each Custom Webhook variable can contain up to 10 million elements by default!