Events & Errors
This reference documents all events and custom errors used throughout the IU2U Protocol smart contracts, providing developers with comprehensive information for monitoring, debugging, and integration.
Core Protocol Events
IU2U Gateway Events
ContractCall
Emitted when a cross-chain contract call is initiated.
event ContractCall(
address indexed sender,
string destinationChain,
string destinationContractAddress,
bytes32 indexed payloadHash,
bytes payload
);Parameters:
sender: Address that initiated the calldestinationChain: Target blockchain namedestinationContractAddress: Target contract addresspayloadHash: Hash of the payload for verificationpayload: Encoded function call data
Usage Example:
ContractCallWithToken
Emitted when a cross-chain contract call with token transfer is initiated.
Parameters:
sender: Address that initiated the calldestinationChain: Target blockchain namedestinationContractAddress: Target contract addresspayloadHash: Hash of the payloadpayload: Encoded function call datasymbol: Token symbol being transferredamount: Amount of tokens being transferred
TokenSent
Emitted when tokens are sent cross-chain.
Executed
Emitted when a cross-chain command is executed on the destination chain.
Parameters:
commandId: Unique identifier for the commandsourceChain: Originating blockchain namesourceAddress: Original caller's addresssuccess: Whether execution was successfulreturnData: Return data from the executed function
IU2U Token Events
TokenMinted
Emitted when IU2U tokens are minted (cross-chain transfer in).
TokenBurned
Emitted when IU2U tokens are burned (cross-chain transfer out).
RelayerAdded
Emitted when a new relayer is added to the network.
RelayerRemoved
Emitted when a relayer is removed from the network.
ChainAdded
Emitted when a new blockchain is added to the protocol.
ChainRemoved
Emitted when a blockchain is removed from the protocol.
DEX Aggregation Events
TokenSwap
Emitted when a token swap is executed through the aggregator.
RouteFound
Emitted when an optimal route is found for a swap.
LiquidityAdded
Emitted when liquidity is added to a DEX through the aggregator.
Protocol Errors
Core Protocol Errors
InvalidChain
Thrown when an unsupported or invalid chain is specified.
Common Causes:
Chain not registered in the protocol
Typo in chain name
Chain temporarily disabled
Resolution:
InvalidRelayer
Thrown when an unauthorized relayer attempts to execute commands.
Common Causes:
Relayer not registered
Relayer stake below minimum
Relayer temporarily suspended
CommandAlreadyExecuted
Thrown when attempting to execute a command that has already been processed.
Common Causes:
Replay attack attempt
Duplicate transaction submission
Race condition in relayer network
InsufficientBalance
Thrown when a user doesn't have enough tokens for an operation.
InvalidSignature
Thrown when signature verification fails.
Common Causes:
Wrong private key used for signing
Signature malformed or corrupted
Domain separator mismatch
PayloadExecutionFailed
Thrown when cross-chain payload execution fails.
DEX Aggregation Errors
InsufficientOutputAmount
Thrown when swap output is below minimum acceptable amount.
NoLiquidityAvailable
Thrown when no liquidity is available for a trading pair.
ExcessiveSlippage
Thrown when price slippage exceeds acceptable limits.
InvalidPath
Thrown when the provided swap path is invalid.
DEXNotSupported
Thrown when trying to use an unsupported DEX.
Event Monitoring Patterns
Basic Event Listening
Advanced Event Filtering
Event Aggregation and Analytics
Error Handling Patterns
Comprehensive Error Handling
React Error Boundary
Best Practices
Event Monitoring
Use Filters: Filter events by user or specific parameters to reduce noise
Handle Reconnections: Implement robust connection handling for WebSocket providers
Store Event History: Cache important events for offline access
Rate Limiting: Implement rate limiting for high-frequency events
Error Handling
Categorize Errors: Distinguish between user errors, network issues, and protocol errors
Implement Retries: Use exponential backoff for transient errors
User Feedback: Provide clear, actionable error messages to users
Monitoring: Track error patterns to identify systemic issues
Performance
Batch Event Queries: Use
queryFilterfor historical data instead of individual callsOptimize Filters: Use indexed parameters in event filters
Connection Pooling: Manage WebSocket connections efficiently
Cleanup: Remove event listeners when components unmount
Resources
Last updated

