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 call

  • destinationChain: Target blockchain name

  • destinationContractAddress: Target contract address

  • payloadHash: Hash of the payload for verification

  • payload: 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 call

  • destinationChain: Target blockchain name

  • destinationContractAddress: Target contract address

  • payloadHash: Hash of the payload

  • payload: Encoded function call data

  • symbol: Token symbol being transferred

  • amount: 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 command

  • sourceChain: Originating blockchain name

  • sourceAddress: Original caller's address

  • success: Whether execution was successful

  • returnData: 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

  1. Use Filters: Filter events by user or specific parameters to reduce noise

  2. Handle Reconnections: Implement robust connection handling for WebSocket providers

  3. Store Event History: Cache important events for offline access

  4. Rate Limiting: Implement rate limiting for high-frequency events

Error Handling

  1. Categorize Errors: Distinguish between user errors, network issues, and protocol errors

  2. Implement Retries: Use exponential backoff for transient errors

  3. User Feedback: Provide clear, actionable error messages to users

  4. Monitoring: Track error patterns to identify systemic issues

Performance

  1. Batch Event Queries: Use queryFilter for historical data instead of individual calls

  2. Optimize Filters: Use indexed parameters in event filters

  3. Connection Pooling: Manage WebSocket connections efficiently

  4. Cleanup: Remove event listeners when components unmount

Resources

Last updated