Tracking USDC transfers with Events
In this tutorial we'll show you how create a Blueprint to track USDC transfers above 100 USDC to/from specific addresses, and how to deploy Streams dynamically based on such Blueprint.
Create a new Stream Blueprint
From the Create Stream Blueprint page, select the Contract Events button
Choose the Network and the Contract Address that is going to emit the event. In this tutorial we want to track USDC transfers above 100 USDC.
Since USDC is deployed behind the proxy, we need to override the ABI automatically fetched by HAL with the ABI of the target contract. You can do so by expanding the Contract ABI menu:
From the list of Event to track, select Transfer:
We are going to add 2 different filters: one is one the value event variable, and we hardcode it greater than 100 (remember to adjust that value based on the decimals of the token, 6 in the case of USDC).
The second filter we want to it to be a variable filter: by checking the variable checkbox, you'll be able to dynamically decide the destination address when deploying a Stream.
Variable filters in Blueprint
You can create Blueprints with variables that will be instantiated dynamically when deploying a Stream. You can learn more about variable filters here: https://docs.hal.xyz/docs/static-and-dynamic-blueprints-variable
Go on and save your first Blueprint!
Deploy a Stream
Now that we have created a Blueprint it's time to deploy our first Stream. It's easy to deploy from the UI, simply go on your Stream Blueprints page and click the Deploy button.
You need to instantiate the to variable with a valid address. This will allow you to deploy multiple streams, tracking multiple addresses, based on the same Blueprint! In this example we're tracking the burn address 0x0.
You can also deploy your Stream programmatically using curl, or any other programming language. We give you snippets of code on the right hand side.
You just deployed your first Stream!
Consuming a Stream
From the "Deployed Stream" page you can have an overview of the Streams you deployed and you can easily manage them (pause or delete a Stream).
Of course you can consume your Stream API from your applications, or from the Terminal or any other app you use to consume APIs. You can refer to our API documentation to see what the Events are like.
curl --request GET \ --url https://api.hal.xyz/v1/streams/d9000a31-c849-462a-a8cd-39fc3abad9df/events \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --header 'X-Api-Key: <YOUR API KEY>'
Updated 6 months ago