Overview
TheOriginSettler contract is the entry point to Eco Routes Protocol via the ERC-7683 standard. It provides a standardized interface for creating cross-chain orders on the origin chain with enhanced security, replay protection, and proper validation.
Contract Location: contracts/ERC7683/OriginSettler.sol
ERC-7683 Compliance
This contract implements the ERC-7683 Cross-Chain Intent Settlement standard, which defines a universal interface for cross-chain order creation and settlement. It supports both:- Onchain orders: User directly calls
open()to create an intent - Gasless orders: Solver calls
openFor()with user’s EIP-712 signature
Key Features
- EIP-712 Signature Verification: Validates gasless orders using typed structured data hashing
- Replay Protection: Prevents duplicate order execution through vault state checking
- Comprehensive Validation: Checks deadlines, chain IDs, and origin settler addresses
- Unified Funding Logic: Atomic intent creation and funding via
_publishAndFund - ERC-7683 Standard Events: Emits
Openevent with resolved order data for off-chain solvers
Core Functions
open
The cross-chain order containing:
fillDeadline: Timestamp by which order must be filledorderDataType: Must equalORDER_DATA_TYPEHASHorderData: ABI-encodedOrderDatastruct
Open(bytes32 indexed orderId, ResolvedCrossChainOrder resolvedOrder)
TypeSignatureMismatch(): IforderDataTypedoesn’t match expected hash
openFor
The gasless order containing:
originSettler: Must match this contract’s addressuser: Address whose signature is verifiednonce: Replay protection nonceoriginChainId: Must match current chain IDopenDeadline: Timestamp by which order must be openedfillDeadline: Timestamp by which order must be filledorderDataType: Must equalORDER_DATA_TYPEHASHorderData: ABI-encodedOrderDatastruct
User’s EIP-712 signature authorizing the order creation
Optional filler-defined data (currently unused)
Open(bytes32 indexed orderId, ResolvedCrossChainOrder resolvedOrder)
OpenDeadlinePassed(): If current timestamp exceedsopenDeadlineInvalidOriginSettler(address expected, address actual): IforiginSettlerdoesn’t match this contractInvalidOriginChainId(uint256 expected, uint256 actual): IforiginChainIddoesn’t match current chainTypeSignatureMismatch(): IforderDataTypedoesn’t match expected hashInvalidSignature(): If signature verification fails
- If intent is Withdrawn or Refunded, transaction fails
- If intent is Initial, it publishes and funds the intent
- If intent is Funded, it publishes but doesn’t double-fund
resolve
ResolvedCrossChainOrder format for off-chain solvers.
Parameters:
The order to resolve
resolveFor
The gasless order to resolve
Optional filler data (currently unused)
domainSeparatorV4
Abstract Methods
_publishAndFund
Destination chain ID where the intent should be executed
Encoded route data containing execution instructions for destination chain
Reward structure containing token amounts, creator, prover, and deadline
Whether to accept partial funding if full funding is not possible
Address providing the funding (
msg.sender for open(), order.user for openFor())Unique identifier of the created or existing intent
Address of the intent’s vault contract for reward escrow
Events
Open
open() or openFor().
Parameters:
Unique identifier for the order (intent hash)
ERC-7683 compliant resolved order data for off-chain solvers
Errors
TypeSignatureMismatch
orderDataType doesn’t match ORDER_DATA_TYPEHASH.
InvalidOriginChainId
OpenDeadlinePassed
openDeadline has passed.
InvalidSignature
InvalidOriginSettler
originSettler address in the order doesn’t match this contract.
InsufficientNativeRewardAmount
EIP-712 Type Hashes
GASLESS_CROSSCHAIN_ORDER_TYPEHASH
Implementation Notes
Security Features
- Replay Protection: The
_publishAndFundmethod checks vault state to prevent duplicate funding - Deadline Validation: Both open and fill deadlines are validated to ensure timely execution
- Chain ID Verification: Ensures orders are executed on the correct chain
- Signature Verification: Uses EIP-712 for secure off-chain authorization
Gas Optimization
- Uses
uint32for timestamps (safe until year 2106) - Efficient ABI encoding/decoding of nested structs
- Direct
orderData.maxSpentusage instead of reconstruction
Integration Guide
To integrate with OriginSettler:- Encode your
OrderDatawith destination, route, reward, portal, deadline, and maxSpent - For onchain orders: call
open()with propermsg.valuefor native rewards - For gasless orders: obtain user’s EIP-712 signature and call
openFor() - Listen for
Openevents to track order creation - Use
resolve()orresolveFor()to get standardized order format for solvers
Related
- DestinationSettler - Settlement contract on destination chain
- OrderData Type - Order data structure
- Reward Type - Reward structure
- ERC-7683 Standard - Official EIP specification