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β
-
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.
-
AppGateway as Orchestrator
- The AppGateway smart contract interprets the intent and determines the optimal execution strategy.
-
Pre-Execution Logic
- Security Checks: Ensures compliance with security standards.
- Auctions: Optimizes execution costs by selecting the best available route.
-
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
);
}
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);
}
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);
}
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);
}
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;
}
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.