The Delegate Contract: The On-Chain Execution Engine
The Delegate contract is the on-chain component that receives and executes the user’s signed instructions. It is the implementation that an EOA delegates its authority to. It acts as the user’s temporary agent on the target chain, ensuring that only the actions specified in the user’s signed Intent are executed.
Key Functions and Concepts
-
IntentandChainBatchStructs: These structs define the core data structure. AnIntentis a collection ofChainBatches, and each batch is a set of calls for a specificchainId. This is how the contract can handle multi-chain instructions. -
execute(Intent calldata intent): This is the primary function for executing a user’s signed intent. The most critical part is the signature verification:if (recovered != address(this)) revert InvalidSignature(recovered, address(this));. When a user’s EOA is delegated to this contract,address(this)is the user’s address for the duration of the transaction. This check ensures that the person who signed the intent is the same person whose authority is being used to execute it. -
selfExecute(Call[] calldata calls): This function is what the solver calls. The key here is theif (msg.sender != address(this)) revert InvalidAuthority();check. The solver submits a transaction that includes the user’s EIP-7702 authorization. This authorization makes the solver’s EOA become theDelegatecontract. Therefore, when the solver callsselfExecuteon itself, themsg.senderisaddress(this), and the check passes. This allows the solver to bundle the user’s intent with other calls, like fee payments or refunding the user.s -
Replay Protection (
_registerSignatureHash): To prevent a malicious actor from re-submitting an old, completed transaction, the contract keeps a history of recently executedChainBatchhashes. It stores these hashes in buckets corresponding to therecentBlockNumberprovided in the batch. It will revert if it finds the same hash has been used in a recent block, preventing double-spending and replay attacks. The history is limited to16blocks to keep storage costs manageable. s -
Timeliness Checks: The contract also ensures that a
ChainBatchis executed within a reasonable time window. It reverts if therecentBlockis in the future (TooEarly) or more than 16 blocks in the past (SignatureExpired).
Overall Flow

