Skip to main content
The Eco Routes Protocol provides comprehensive encoding utilities for creating and hashing intents, routes, rewards, and standard contract function calls.

Intent Encoding

Utilities for encoding and hashing intent-related data structures.

encodeRoute

Encodes a route object into ABI-encoded bytes for on-chain processing.
Parameters:
  • route: Route object containing execution details
Returns: ABI-encoded route data as hex stringExample:

encodeReward

Encodes a reward object into ABI-encoded bytes.
Parameters:
  • reward: Reward object containing payment details for intent fulfillment
Returns: ABI-encoded reward data as hex stringExample:

encodeIntent

Encodes a complete intent object combining destination, route, and reward.
Parameters:
  • intent: Complete intent object
Returns: ABI-encoded intent data as hex string Example:

Intent Hashing

hashIntent

Generates cryptographic hashes for an intent and its components. These hashes are used for CREATE2 address prediction and intent identification.
Parameters:
  • intent: Intent to hash
Returns: Object containing:
  • routeHash: keccak256 hash of the encoded route
  • rewardHash: keccak256 hash of the encoded reward
  • intentHash: keccak256 hash of solidityPacked(destination, routeHash, rewardHash)
Example:
Hash Computation:

intentVaultAddress

Predicts the deterministic CREATE2 vault address for an intent before it’s deployed.
Parameters:
  • intentSourceAddress: Address of the IntentSource contract that will deploy the vault
  • intent: Intent object to calculate vault address for
Returns: Predicted CREATE2 vault contract address Example:
CREATE2 Computation: The vault address is computed using:
  • Deployer: intentSourceAddress (IntentSource contract)
  • Salt: routeHash from the intent
  • Init code: Vault bytecode + ABI-encoded constructor args (intentHash, reward)

Function Call Encoding

Utilities for encoding common contract function calls.

encodeTransfer

Encodes an ERC20 transfer function call.
Parameters:
  • to: Recipient address
  • value: Amount to transfer (in token’s smallest unit)
Returns: Encoded calldata for transfer(address,uint256) Example:

encodeTransferNative

Encodes a native token transfer function call.
Parameters:
  • to: Recipient address
  • value: Amount of native tokens to transfer (in wei)
Returns: Encoded calldata for transferNative(address,uint256) Example:

encodeTransferPayable

Encodes a payable transfer function call.
Parameters:
  • to: Recipient address
  • value: Amount to transfer
Returns: Encoded calldata for transferPayable(address,uint256)

encodeIdentifier

Generates a unique identifier hash from counter and chain ID.
Parameters:
  • counter: Counter value (e.g., nonce, sequence number)
  • chainid: Chain ID
Returns: keccak256 hash of ABI-encoded counter and chainid Example:

ERC-7683 Encoding

Utilities for encoding cross-chain orders according to the ERC-7683 standard.

encodeOnchainCrosschainOrderData

Encodes on-chain cross-chain order data compatible with ERC-7683.
Example:

encodeGaslessCrosschainOrderData

Encodes gasless cross-chain order data for permit-based intents.
Example:

encodeOnchainCrosschainOrder

Encodes a complete on-chain cross-chain order including fill deadline and order type.
Example:

Complete Example

Here’s a complete example creating and encoding an intent: