Overview
In this section, we walk you through how to implement the Chainrails Intent Broadcaster in your Cairo contracts on Starknet.Step 1 — Import required interfaces and types
Import the broadcaster dispatcher, ERC20 dispatcher, and shared types.Imports
Step 2 — Define your contract interface
Expose functions for broadcasting, canceling, and querying execution/escrow status.Contract Interface
Step 3 — Add utility for token address encoding
Chainrails token representation usesu256, so convert Starknet ContractAddress to u256.
Address Utils
Step 4 — Store broadcaster address and initialize it
Persist the broadcaster address in storage and validate it in constructor.Storage and Constructor
Step 5 — Broadcast an intent
Create a function that escrows funds, approves broadcaster spend, buildsBroadcastedIntent + deposits, and calls broadcast_intent.
Broadcast Intent
Cancellation and Refunds
Cancellation and refunds of broadcasted intents are handled automatically after intent expiration (typically around 1 hour after broadcasting). You can also support manual cancel from your broadcasting contract:Cancel Broadcast
refund_address.
Github Example
Find the full implementation of the above example in the GitHub repository.

