Overview
In this section, we walk you through how to implement the Chainrails Intent Broadcaster in your smart contracts on EVM-compatible chains.Step 1 — Import the Interface
First, create and import theIIntentBroadcaster interface into your contract.
Import
Step 2 — Define the required types
Next, define theBroadcastedIntent, Chain and TokenAmount objects in your contract. These are used to structure the data for broadcasting an intent.
Types
Step 3 — Create a util function to encode token address
Encode to bytes32
Step 4 — Create the Intent Broadcaster Instance
Create an instance of theIIntentBroadcaster interface in your contract, pointing to the deployed IntentBroadcaster contract address.
Intent Broadcaster Instance
Step 5 — Broadcast an Intent
Now you can create a function in your contract to broadcast an intent using thebroadcastIntent function from the IIntentBroadcaster interface. This function will take in the necessary parameters, structure the BroadcastedIntent object, and call the broadcaster to broadcast the intent.
Broadcast Intent
Cancellation and Refunds
Cancellation and refunds of broadcasted intents are handled automatically like a normal intent after the intent expiration (typically in 1 hour after broadcasting). You can also choose to implement a function in your contract to allow users to manually cancel their broadcasted intents before expiration by calling thecancelBroadcast function from the IIntentBroadcaster interface.
Cancel Broadcast
refundAddress.
Github Example
Find the full implementation of the above example in the GitHub repository.

