Skip to main content

Overview

The CompactIntentExecutor enables secure cross-chain intent execution through a two-phase process using The Compact protocol for cross-chain verification. Source: /src/executor/CompactIntent/CompactIntentExecutor.sol:41

Two-Phase Execution Flow

Phase 1 (Origin Chain): executePreClaimOpsWithCompactStub
  • User signs an EIP-712 structured intent specifying cross-chain operations
  • Arbiter calls this function to execute pre-claim operations (e.g., token approvals)
  • Contract validates signature and computes claim hash for cross-chain verification
Phase 2 (Destination Chain): executeTargetOpsWithCompactStub
  • Arbiter provides proof of origin chain execution via claim hash
  • Contract validates the claim hash through The Compact protocol’s verification system
  • If valid, executes the target operations on behalf of the user

Security Model

The security relies on:
  • EIP-712 signatures for user authorization
  • The Compact protocol’s cross-chain verification system
  • Router-only access control for cross-chain operations
  • Expiration timestamps to prevent stale execution

Structs

EIP712CompactStub

Core Compact order data that remains consistent across all elements.
nonce
uint256
Unique nonce for this Compact order to prevent replay attacks
expires
uint256
Timestamp after which the entire Compact order expires
notarizedChainId
uint256
Chain ID where the order was originally notarized/signed

EIP712ElementStubOrigin

Stub data for EIP-712 element construction on origin chain.
otherElements
bytes32[]
Array of other element hashes in the Compact Merkle tree
minGas
uint128
Minimum gas required for executing operations
elementOffset
uint256
Index position where this element should be inserted in the otherElements array
destOpsHash
bytes32
Hash of target operations that will be executed on destination chain
tokenInHash
bytes32
Hash of input token details for this element
targetAttributesHash
bytes32
Pre-computed hash of target attributes (account, tokenOut, chain, expires)
qHash
bytes32
Hash of the qualifier data specific to this element

EIP712ElementStubDestination

Stub data for EIP-712 element construction on destination chain.
sponsor
address
Address that sponsored the original Compact order
otherElements
bytes32[]
Array of other element hashes in the Compact Merkle tree
elementOffset
uint256
Index position where this element should be inserted in the otherElements array
preClaimOpsHash
bytes32
Hash of pre-claim operations that were executed on origin chain
tokenInHash
bytes32
Hash of input token details for this element
tokenOutHash
bytes32
Hash of output token details for this element
fillExpires
uint256
Timestamp after which the fill operation expires
qHash
bytes32
Hash of the qualifier data specific to this element

Functions

executePreClaimOpsWithCompactStub

Executes pre-claim operations on the origin chain before cross-chain transfer.
account
address
required
The smart account address that owns the assets and signed the order
compactStub
EIP712CompactStub
required
Core Compact order data (nonce, expires, notarized chain)
elementStub
EIP712ElementStubOrigin
required
Element-specific data needed for origin chain execution
preClaimOps
Types.Operation
required
Operations to execute before cross-chain transfer (e.g., token approvals)
signature
bytes
required
EIP-712 signature from the account authorizing these operations
Returns:
  • sigOk (bool): True if signature validation passed
  • execOk (bool): True if pre-claim operations executed successfully
The caller (arbiter) is responsible for facilitating the cross-chain transfer. The arbiter address is included in the element hash computation.

executeTargetOpsWithCompactStub

Executes target operations on the destination chain with claim hash verification.
account
address
required
The recipient account address for the target operations
notarizedArbiter
address
required
The arbiter address that notarized the cross-chain transfer
compactStub
EIP712CompactStub
required
Core Compact order data (nonce, expires, notarized chain)
elementStub
EIP712ElementStubDestination
required
Element-specific data needed for destination chain execution
targetOps
Types.Operation
required
Operations to execute on the destination chain
signature
bytes
required
EIP-712 signature authorizing the target operations
Returns: bytes32 - The computed claim hash used for verification
This function can only be called by the authorized router contract. Direct calls will revert with OnlyRouter() error.

isCompactIntentNonceConsumed

Checks if a nonce has been used for a specific account.
nonce
uint256
required
The nonce value to check
account
address
required
The account address that owns the nonce
Returns: bool - True if the nonce has been consumed, false otherwise

Execution Process

Origin Chain (Phase 1)

  1. Hash Computation: Reconstruct element hash using caller as arbiter
  2. Merkle Tree: Build complete Compact Merkle tree with all elements
  3. Claim Hash: Compute final EIP-712 claim hash
  4. Signature Validation: Verify user’s signature authorizing the operations
  5. Nonce Consumption: Mark nonce as used to prevent replay
  6. Execution: Execute pre-claim operations (typically token approvals)

Destination Chain (Phase 2)

  1. Hash Reconstruction: Recreate element hash from stub data
  2. Validation: Check correct chain and expiration
  3. Merkle Tree: Build complete Compact Merkle tree
  4. Claim Hash: Compute EIP-712 claim hash (must match origin)
  5. Signature Validation: Verify signature against claim hash
  6. Nonce Consumption: Mark nonce as used to prevent replay
  7. Execution: Execute target operations on destination chain

Example Usage

Error Handling

InvalidSignature
error
Thrown when signature validation fails
InvalidParams
error
Thrown when fill expiration has passed or parameters are invalid
OnlyRouter
error
Thrown when executeTargetOpsWithCompactStub is called by non-router address

Security Considerations

Nonce Management: Each Compact intent uses a unique nonce to prevent replay attacks. Nonces are consumed on both origin and destination chains.
Expiration Validation: Both the overall order expiration (expires) and fill expiration (fillExpires) are validated. Ensure adequate time windows.
Claim Hash Matching: The claim hash computed on the destination chain must exactly match the one from the origin chain. All element parameters must be provided correctly.