Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/rhinestonewtf/warp-router/llms.txt

Use this file to discover all available pages before exploring further.

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.
struct EIP712CompactStub {
    uint256 nonce;
    uint256 expires;
    uint256 notarizedChainId;
}
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.
struct EIP712ElementStubOrigin {
    bytes32[] otherElements;
    uint128 minGas;
    uint256 elementOffset;
    bytes32 destOpsHash;
    bytes32 tokenInHash;
    bytes32 targetAttributesHash;
    bytes32 qHash;
}
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.
struct EIP712ElementStubDestination {
    address sponsor;
    bytes32[] otherElements;
    uint256 elementOffset;
    bytes32 preClaimOpsHash;
    bytes32 tokenInHash;
    bytes32 tokenOutHash;
    uint256 fillExpires;
    bytes32 qHash;
}
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

function executePreClaimOpsWithCompactStub(
    address account,
    EIP712CompactStub calldata compactStub,
    EIP712ElementStubOrigin calldata elementStub,
    Types.Operation calldata preClaimOps,
    bytes calldata signature
) external returns (bool sigOk, bool execOk)
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

function executeTargetOpsWithCompactStub(
    address account,
    address notarizedArbiter,
    EIP712CompactStub calldata compactStub,
    EIP712ElementStubDestination calldata elementStub,
    Types.Operation calldata targetOps,
    bytes calldata signature
) external onlyRouter returns (bytes32 claimHash)
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

function isCompactIntentNonceConsumed(
    uint256 nonce,
    address account
) external view returns (bool used)
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

// Origin chain: Execute pre-claim operations
(bool sigOk, bool execOk) = intentExecutor.executePreClaimOpsWithCompactStub(
    accountAddress,
    EIP712CompactStub({
        nonce: 1,
        expires: block.timestamp + 1 hours,
        notarizedChainId: 8453 // Base
    }),
    elementStub,
    preClaimOps,
    userSignature
);

require(sigOk && execOk, "Execution failed");

// Destination chain: Execute target operations (via router)
bytes32 claimHash = router.executeTargetOpsWithCompactStub(
    recipientAddress,
    arbiterAddress,
    compactStub,
    destElementStub,
    targetOps,
    userSignature
);

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.

Build docs developers (and LLMs) love