Step-by-step for creating a template to filter out event configuration.
Step 1. Create a New Template
Transactions contain much information, but you might not need all the fields. Creating a template allows you to filter and receive only the necessary information.
Request Payload
Replace YOUR_ACCESS_TOKEN
with your API key for authentication. Learn how to get your API key here.
curl -X POST "https://svc.Blockdaemon.com/streaming/v1/templates" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d ' {
"description": "Basic block email",
"name": "Basic block email",
"template": "<h1 style=\"margin: 0 0 10px 0;mso-line-height-rule: exactly;font-size: 40px;line-height: 44px;font-weight: 400;font-family: sans-serif;color: #5025B8;margin-bottom: 36px;\"> Theres a new: {{ .bd_metadata.schema }} </h1> <p style=\"margin: 0 0 10px 0;mso-line-height-rule: exactly;font-family: sans-serif;font-weight: 400;color: #211B4E;font-size: 16px;line-height: 24px;margin-bottom: 20px;\"> \tParent Block:{{ .parentBlock }} </p> <p style=\"margin: 0 0 10px 0;mso-line-height-rule: exactly;font-family: sans-serif;font-weight: 400;color: #211B4E;font-size: 16px;line-height: 24px;margin-bottom: 20px;\"> \tBlock Hash: {{ .blockHash }} </p> <p style=\"margin: 0 0 10px 0;mso-line-height-rule: exactly;font-family: sans-serif;font-weight: 400;color: #211B4E;font-size: 16px;line-height: 24px;margin-bottom: 20px;\"> \tAt block Height: {{ .height }} </p> "
}
The request includes the following parameters:
Fields | Details | |
---|---|---|
name | Required | The template name. Each resource should have a unique name. |
description | Optional | The template description. |
template | Required | The template content can contain a JSON format or HTML code with placeholders like {{ .bd_metadata.schema }} and {{ .parent }} that will be dynamically filled during processing. |
Response Payload
A successful result will return a template in JSON format.
{
"created_at": "2024-02-05T13:53:11.223232Z",
"description": "block email",
"id": "<TEMPLATE_ID>",
"name": "block email",
"template": "<h1 style=\"margin: 0 0 10px 0;mso-line-height-rule: exactly;font-size: 40px;line-height: 44px;font-weight: 400;font-family: sans-serif;color: #5025B8;margin-bottom: 36px;\"> Theres a new: {{ .bd_metadata.schema }} </h1> <p style=\"margin: 0 0 10px 0;mso-line-height-rule: exactly;font-family: sans-serif;font-weight: 400;color: #211B4E;font-size: 16px;line-height: 24px;margin-bottom: 20px;\"> \tParent Block:{{ .parentBlock }} </p> <p style=\"margin: 0 0 10px 0;mso-line-height-rule: exactly;font-family: sans-serif;font-weight: 400;color: #211B4E;font-size: 16px;line-height: 24px;margin-bottom: 20px;\"> \tBlock Hash: {{ .blockHash }} </p> <p style=\"margin: 0 0 10px 0;mso-line-height-rule: exactly;font-family: sans-serif;font-weight: 400;color: #211B4E;font-size: 16px;line-height: 24px;margin-bottom: 20px;\"> \tAt block Height: {{ .height }} </p> ",
"updated_at": "2024-02-05T13:53:11.223232Z"
}
Step 2. Update a Rule with a Template
Update the rule by applying the template. Replace TEMPLATE_ID
with the ID of the template you've just created.
curl -X PUT "https://svc.Blockdaemon.com/streaming/v1/rules/YOUR_RULE_ID" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"condition": [
{
"variable_id": "<VARIABLE_ID>",
"variable_type": "source-address"
},
{
"variable_id": "<VARIABLE_ID>",
"variable_type": "destination-address"
}
],
"condition_type": "match_var",
"created_at": "2024-02-05T13:29:23.2179Z",
"description": "Ethereum mainnet demo",
"id": "<RULE_ID>",
"isActive": true,
"name": "Ethereum mainnet demo",
"network": "mainnet",
"protocol": "ethereum",
"target": "<TARGET_ID>",
"template": "<TEMPLATE_ID>"
}
👋 Need Help?
Contact us through email or our support page for any issues, bugs, or assistance you may need.