executeWithCrossChainToken and return
EXECUTE_SUCCESS.
For background, see Hooks.
Prerequisites
Before you begin, ensure that you’ve:- Set up a Solidity development environment (Foundry, Hardhat, or similar)
- Located the local
CrossChainTokenServiceaddress
Steps
1
Implement executeWithCrossChainToken
Create a contract that exposes the hook entrypoint the destination service
calls. Restrict the caller to the local
CrossChainTokenService, run your
logic, and return EXECUTE_SUCCESS.Solidity
2
Deploy the receiver on every destination blockchain
Deploy the receiver on every blockchain where transfers will arrive with hook
data. Each deployment must bind to the local
CrossChainTokenService.3
Send a transfer with hook data
On the source blockchain, encode the hook payload and call
The
crossChainTransfer with
destinationAddress set to the receiver contract and autoExecuteHookData set
to true.TypeScript
claim and feeTotalAmount values are returned by the Iris fee-quote
endpoint. Use a standard quote body (amount + feeToken only) unless your
token is enabled for fast transfer. Do not include FORWARD when
autoExecuteHookData is true—hook transfers require self-relay. See
QuoteClaim.For BURN_MINT or LOCK_UNLOCK tokens, approve the source TokenManager (not
the service) before calling crossChainTransfer.4
Relay the message to the destination
Iris does not relay transfers that carry hook data with
autoExecuteHookData
set to true. After Iris attests the source blockchain message, you or your own
relayer must call receiveMessage on the destination MessageTransmitterV2 to
deliver the transfer and trigger the hook. See
Self-relay required for hook transfers.When the destination service receives the message, it delivers the tokens and
calls your receiver’s hook in the same transaction.