Prerequisites
Before you begin:- Create an API key in the Circle Console
- Step 1. Configure Your Webhook for Notifications
- Step 2. Import Your Smart Contract
- Step 3. Create an Event Monitor
- Step 4. Fetch Event History
Step 1. Configure Your Webhook for Notifications
To receive notifications from Circle, you must expose a publicly accessible subscriber endpoint on your side. This endpoint should handle POST requests over HTTPS. For more information on setting up a webhook, refer to the Set up a webhook endpoint, and optionally watch the following video about Webhook Configurations.Video Tutorial: Webhook Configuration
Video Tutorial: Webhook Configuration
Customized Webhook Notifications
Customized webhook notifications enable you to listen to a restricted set of notifications. To create a webhook for smart contract events only select Limit to specific events when creating your webhook in the Circle Console, then choose contracts.EventLog.The Event Log Notification
When a monitored event occurs, the webhook will receive a notification via POST with the body formatted as follows: NotificationJSON
Step 2. Import Your Smart Contract
Before creating an event monitor, import your smart contract into the Contracts system. This ensures the Contracts platform is aware of your contract and can manage event monitors effectively:javascript
JSON
Step 3. Create an Event Monitor
Event Monitors listen for configured events on the blockchain and trigger notifications to your webhook endpoint when those events occur. Circle will also save all emitted events under that monitor, allowing you to retrieve historical data later. For more details, see Step 4. Fetch Event History.Finding and Using the Event Signature
An event signature uniquely identifies an event within a smart contract and is derived from the event’s name and parameter types using the keccak-256 hashing function. For readability, event monitors are created using the human-readable event signature, not the hash. For example, the Transfer event in the ERC-20 interface is defined as:JavaScript
Note: Spaces are not allowed in the event string signature.
JavaScript
JSON
JSON
Note: Please ensure the event signature exists if you are using an
unverified contract as Circle cannot verify event existence for unverified
contracts.
Step 4. Fetch Event History
To retrieve historical events that match your monitors, utilize the event history feature. This functionality is essential for doing analytics, auditing, or reconstructing the application state based on past events:JavaScript
JSON
Note:Event history for a monitor will always be available; however, the resource will
stop being populated once the monitor is deleted.