Skip to main content

Overview

The Route struct defines the complete set of instructions for executing a cross-chain message on the destination chain. It specifies where to send the message, what calls to make, what tokens are required, and the execution deadline. Type Location: contracts/types/Intent.sol

Route

Defines the routing and execution instructions for cross-chain messages.

Fields

bytes32
Unique identifier provided by the intent creator to prevent duplicate intents.Purpose:
  • Ensures intent uniqueness even with identical execution parameters
  • Prevents replay attacks and duplicate submissions
  • Allows creating multiple similar intents with different salts
Generation:
Best Practice: Use a combination of user address, timestamp, and a user-specific nonce to ensure global uniqueness.
uint64
Timestamp by which the route must be executed on the destination chain.Format: Unix timestamp (seconds since epoch)Validation:
  • Must be greater than current block.timestamp when intent is created
  • Should be less than reward.deadline to allow time for proof submission
  • Typical range: 10 minutes to 24 hours from intent creation
Example:
Note: Using uint64 is safe until the year 2262 (far beyond uint32’s 2106 limit).
address
Address of the portal contract on the destination chain that receives and processes the message.Role:
  • Receives the cross-chain message from the prover
  • Validates message authenticity and authorization
  • Executes the route’s calls in sequence
  • Handles token transfers and native token forwarding
Requirements:
  • Must implement the IPortal interface
  • Must be deployed at the same address on the destination chain
  • Should be a trusted contract authorized to make calls on behalf of users
Example:
uint256
Amount of native tokens (in wei) to send with the route execution.Purpose:
  • Provides native tokens for executing calls that require ETH/native payment
  • Covers gas costs for complex execution sequences
  • Enables native token swaps or transfers
Source:
  • Provided by the solver/filler when executing fill() on destination chain
  • Must be included in maxSpent outputs in ERC-7683 orders
Example:
Note: Use 0 if no native tokens are required for execution.
TokenAmount[]
Array of ERC20 tokens and amounts required for execution of calls on the destination chain.Purpose:
  • Specifies which tokens the solver must provide
  • Portal transfers these tokens to call targets as needed
  • Enables token swaps, liquidity provision, and multi-token operations
Structure:
Example:
Important: Always use the correct decimal precision for each token.See TokenAmount Type for more details.
Call[]
Array of contract calls to execute on the destination chain in sequence.Purpose:
  • Defines the actual operations to perform (swaps, transfers, contract interactions)
  • Executed sequentially by the portal contract
  • Each call can send native tokens and invoke arbitrary contract functions
Structure:
Example:
Execution Order: Calls are executed in array order. If any call fails, the entire transaction reverts.See Call Type for more details.

Route Encoding

When used in OrderData for ERC-7683 orders, the route is ABI-encoded:

Route Hash Calculation

Routes are hashed for intent identification:
This hash is combined with the reward hash and destination to create the unique intent hash:

Usage Examples

Simple Token Transfer

Multi-Step DeFi Operation

Native Token Swap


Validation and Security

Pre-Execution Checks

Before executing a route, implementations should validate:
  1. Deadline: block.timestamp <= route.deadline
  2. Portal: Portal address matches expected contract
  3. Token Balances: Portal has sufficient tokens after solver transfers
  4. Native Amount: Sufficient native tokens provided with fill() call

Execution Safety

  1. Sequential Execution: Calls execute in order; any failure reverts entire transaction
  2. Reentrancy Protection: Portal should implement reentrancy guards
  3. Token Approvals: Ensure tokens are approved for portal before execution
  4. Gas Limits: Complex routes may hit gas limits; test thoroughly

Best Practices

  1. Salt Generation: Use unique, unpredictable salts to prevent collisions
  2. Deadline Setting: Allow enough time for cross-chain message delivery (10-60 minutes typical)
  3. Token Precision: Always use correct decimal places for token amounts
  4. Call Ordering: Order calls logically (approvals before transfers, etc.)
  5. Error Handling: Design calls to fail gracefully with clear error messages
  6. Gas Estimation: Test routes on destination chain to ensure gas efficiency

Integration with ERC-7683

The Route is central to ERC-7683 integration:
  1. Order Creation: Route encoded in OrderData.route
  2. Resolution: Route hash included in ResolvedCrossChainOrder.fillInstructions[0].originData
  3. Fill Execution: Route decoded and executed by DestinationSettler.fill()
Origin Chain (Open):
Destination Chain (Fill):