ERC-7521 · Draft · ERC · 2023-09-19
ERC-7521: General Intents for Smart Contract Wallets
An ERC-4337-style entry point for intents: smart contract wallets verify one signature, while pluggable 'intent standard' contracts define what the intent means and solvers bundle intents into a single transaction.
What problem does it solve?
An intent is a signed statement of what a user wants ("swap up to 1,000 USDC for at least 0.3 ETH") rather than the exact transaction to run. Third parties, called solvers, compete to fulfil it. Intent formats keep evolving, and if every new format required a wallet upgrade, users would be stuck with whatever their wallet supports today.
ERC-7521 separates the two concerns. The wallet only proves "yes, I signed this". The meaning of the intent is defined by separate intent standard contracts that anyone can register. A wallet that supports ERC-7521 once can use any current or future intent standard without upgrading.
How it works
UserIntent. A user signs { sender, segments[], signature }. Each segment is a bytes blob whose first 32 bytes is the ID of the intent standard that interprets it. One intent can combine segments from several standards (for example "release these tokens" + "require I receive those tokens").
IntentSolution. A solver collects intents (often including its own) into { timestamp, intents[], order[] } and calls handleIntents(solution) on a shared entry point contract. The solver pays the gas.
Entry point, in two loops:
- Verification: checks the solution timestamp, then calls
validateUserIntent(intent, hash)on each wallet. A failing intent is skipped (or the whole call may revert). - Execution: for each segment, calls
executeIntentSegment(solution, executionIndex, segmentIndex, context)on the matching intent standard. Each standard returns acontextblob that is fed back on that intent's next segment, letting it check state changes across interleaved intents.order[]lets the solver interleave segments of different intents; otherwise a default round-robin is used.
Wallet callbacks. If a standard needs the wallet to act (for example to move tokens), it calls the wallet's generalizedIntentDelegateCall(data). The wallet first asks the entry point verifyExecutingIntentSegmentForStandard(msg.sender) to make sure the caller is the standard currently executing one of its intents, then delegate-calls it.
Standards register permissionlessly with registerIntentStandard, which returns an ID unique to the standard, entry point and chain. Optional extensions include built-in common standards, handleIntentsMulti, entry-point nonce storage, and "data blob" intents.
Sample code
The wallet-side hooks:
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
struct UserIntent { address sender; bytes[] segments; bytes signature; }
interface IEntryPoint {
function verifyExecutingIntentSegmentForStandard(address standard) external view returns (bool);
}
abstract contract IntentWallet {
IEntryPoint public immutable entryPoint;
constructor(IEntryPoint ep) { entryPoint = ep; }
function _isValidSignature(bytes32 hash, bytes calldata sig) internal view virtual returns (bool);
function validateUserIntent(UserIntent calldata intent, bytes32 intentHash) external view {
require(msg.sender == address(entryPoint), "not entry point");
require(_isValidSignature(intentHash, intent.signature), "bad signature");
}
function generalizedIntentDelegateCall(bytes memory data) external {
require(entryPoint.verifyExecutingIntentSegmentForStandard(msg.sender), "not executing");
(bool ok, ) = msg.sender.delegatecall(data);
require(ok, "delegatecall failed");
}
}
Things to know
- Status is Draft. The spec points to an external reference implementation; there is no canonical deployed entry point defined in the spec.
- The entry point is a single trust point for every ERC-7521 wallet, so it needs heavy auditing and formal verification. So does every intent standard a user signs for, because the wallet will delegate-call into it.
- Nonce and replay protection are expected to be handled by an intent segment (or the nonce extension), not by
validateUserIntent. - Wallets that already support ERC-4337 can reuse much of their
validateUserOplogic. For a narrower, cross-chain-focused intent format, see ERC-7683.