Step 5. Create a Rule
Easily create new rules for event handling and management.
NoteEach call incurs a fixed CU charge, plus additional CUs for API operations. See the Compute Units Usage page for details.
If you have the following items:
- ✅ Webhook target that has undergone a verification process.
- ✅ Variable(s) with values.
, Then you are ready to create a rule to obtain the data you want.
How it works?
Any transactions that meet the conditions
specified in the rule will send events directly to you through the webhook target. This can be done using the Rules endpoint.
Request Payload
curl --location 'https://svc.blockdaemon.com/streaming/v2/rules' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
"condition": [
{
"variable_type": "address",
"variable_id": "3c1c1483-d8e0-4ecb-95a0-1e18a5d03244"
}
],
"description": "Polkadot mainnet rule",
"is_active": true,
"name": "Polkadot mainnet rule",
"network": "mainnet",
"protocol": "polkadot",
"target": "8918a2f1-28d6-4e2f-837b-fb49ec09daaf",
"condition_type": "match_var"
}'
The request body includes the following parameters:
Field | Required/Optional | Description |
---|---|---|
| Required | An array that defines the conditions for the rule. You can reference multiple variable types. Transactions that meet these conditions are going to the target. |
| Required | Type of the variable in the selected protocol. You can find it in the supported protocols and networks endpoint. |
| Required | The variable ID within the condition. Please refer to this page to create a new variable. |
| Required | By default, the value is set to |
| Required | Name of the rule. Each resource should have a unique name. |
| Optional | Description of the rule. |
| Required | Specifies the network for which the rule should be applied. |
| Required | Specifies the protocol for which the rule should be applied. |
| Required | The target where the rule will be applied to send data. Please refer to this page to create a new target. |
| Optional | This is a predefined template other than the Events Unified Format . If no template is provided or if you use the Please refer to this page to create a custom template. |
| Required | Type of condition used in the rule, in this case: |
Response Payload
A successful request will return the output below.
{
"condition": [
{
"variable_id": "3c1c1483-d8e0-4ecb-95a0-1e18a5d03244",
"variable_type": "address"
}
],
"condition_type": "match_var",
"created_at": "2024-03-06T14:57:10.019668Z",
"description": "Polkadot mainnet rule",
"id": "9e2a6c91-18b1-42a4-864b-b3c4efaa5397",
"is_active": true,
"name": "Polkadot mainnet rule",
"network": "mainnet",
"protocol": "polkadot",
"safe_distance": 0,
"safe_timeout": 0,
"target": "8918a2f1-28d6-4e2f-837b-fb49ec09daaf",
"template": "ALL_DATA",
"type": "all",
"updated_at": "2024-03-06T14:57:10.019668Z"
}
It includes the following details:
Field | Description |
---|---|
| An array of the conditions for the rule. Each element is a JSON object referencing a For example:
|
| Type of the variable in the selected protocol. You can find it in the supported protocols and networks endpoint. |
| The variable ID within the condition. Please refer to this page to create a new variable. |
| By default, the value is set to |
| Name of the rule. Each resource should have a unique name. |
| Description of the rule. |
| Specifies the network for which the rule should be applied. |
| Specifies the protocol for which the rule should be applied. |
| The target where the rule will be applied to send data. Please refer to this page to create a new target. |
| This is a predefined template other than the Events Unified Format. If no template is provided or if you use the Please refer to this page to create a custom template. |
| Type of condition used in the rule, in this case: |
👋 Need Help?
Contact us through email or our support page for any issues, bugs, or assistance you may need.
Updated 25 days ago