Skip to main content

Intent-Based Multi-Chain Execution

The Ethereum Improvement Proposal (EIP) 7683 introduces a framework for "Intents", allowing users to specify desired outcomes without managing the complexities of transaction execution. By integrating this with SOCKET Protocol, we can create an intent-based multi-chain system that utilizes an AppGateway smart contract as an orchestrator to facilitate and verify transactions across multiple blockchains.

Architecture​

  1. Define User Intents

    • Users specify high-level intents such as swapping assets across chains.
    • Example: Swap Token A on Chain X for Token B on Chain Y.
  2. AppGateway as Orchestrator

    • The AppGateway smart contract interprets the intent and determines the optimal execution strategy.
  3. Pre-Execution Logic

    • Security Checks: Ensures compliance with security standards.
    • Auctions: Optimizes execution costs by selecting the best available route.
  4. Execution via SOCKET Components

    • Watchers: Monitor blockchain states and generate execution proofs.
    • Transmitters: Submit proofs onchain to trigger execution.
    • Switchboards: Validate and authorize transactions before finalization.

Key Contract Implementations​

Opening a Cross-Chain Order via AppGateway​

Gasless Order (User Signs, Filler Executes)​

function openGaslessOrder(
address settlementForwarder,
GaslessCrossChainOrder calldata order,
bytes calldata signature,
bytes calldata originFillerData
) external async {
// Calls the origin settler’s openFor function
IOriginSettler(settlementForwarder).openFor(
order,
signature,
originFillerData
);
}
note

Allows a filler to execute an order on behalf of a user.

Onchain Order (User Directly Opens)​

function openOnchainOrder(
address settlementForwarder,
OnchainCrossChainOrder calldata order
) external async {
// user calls gateway, gateway calls settler
IOriginSettler(settlementForwarder).open(order);
}
note

Users can directly open a cross-chain order through the Application Gateway.

Deploying & Initializing the Settlement Contracts​

function deployContracts(uint32 chainSlug) external async {
_deploy(settlementId, chainSlug);
}
note

Deploys the required contracts across multiple chains.

Resolving & Filling Orders on the Destination Chain​

Resolving a Gasless Order​

function resolveFor(
GaslessCrossChainOrder calldata order,
bytes calldata originFillerData
) external view override returns (ResolvedCrossChainOrder memory) {
bytes32 orderId = _computeOrderId(order.user, order.nonce);
return _resolveInternalGasless(order, originFillerData, orderId);
}
note

Verifies an order before it is executed on the destination chain.

Filling an Order (Delivering Funds to the User)​

function fill(
bytes32 orderId,
bytes calldata originData,
bytes calldata fillerData
) external override {
require(openedOrders[orderId], "Order not opened");
require(!filledOrders[orderId], "Order already filled");

// Execute cross-chain settlement logic...
filledOrders[orderId] = true;
}
note

Finalizes the transaction by transferring assets to the recipient.

Benefits of This Approach​

  • Simplified User Experience: Users declare outcomes and the system handles execution.
  • Security & Verification: Pre-execution checks ensure order validity.
  • Optimized Execution: Auctions and best-route selection improve efficiency.