Delegator accounts
MetaMask delegator accounts are ERC-4337 smart contract accounts (SCAs), which support programmable account behavior and advanced features such as multi-signature approvals, automated transaction batching, and custom security policies. Unlike traditional wallets, which rely on private keys for every transaction, MetaMask delegator accounts use smart contracts to govern account logic.
Account abstraction (ERC-4337)
Account abstraction, specified by ERC-4337, is a mechanism that enables users to manage SCAs containing arbitrary verification logic. ERC-4337 enables SCAs to be used as primary accounts in place of traditional private key-based accounts, or externally owned accounts (EOAs).
ERC-4337 introduces the following concepts:
-
User operation - A package of instructions signed by a user, specifying actions for the SCA to execute. User operations are collected and submitted to the network by bundlers.
-
Bundler - A service that collects multiple user operations, packages them into a single transaction, and submits them to the network, optimizing gas costs and transaction efficiency.
-
Entry point contract - A contract that validates and processes bundled user operations, ensuring they adhere to the required rules and security checks.
-
Paymasters - Entities that handle the payment of gas fees on behalf of users, often integrated into SCAs to facilitate gas abstraction.
Delegator account flow
The MetaMask delegator account flow is as follows:
-
Account setup - A user creates an SCA by deploying a smart contract, and initializing it with ownership and security settings. The user can customize the SCA in the following ways:
-
Account logic - They can configure custom logic for actions such as multi-signature approvals, spending limits, and automated transaction batching.
-
Security and recovery - They can configure advanced security features such as two-factor authentication and mechanisms for account recovery involving trusted parties.
-
Gas management - They can configure flexible gas payment options, including alternative tokens or third-party sponsorship.
-
-
User operation creation - For actions such as sending transactions, a user operation is created with necessary details and signed by the account owner.
-
Bundlers and mempool - The signed user operation is submitted to a special mempool, where bundlers collect and package multiple user operations into a single transaction to save on gas costs.
-
Validation and execution - The bundled transaction goes to an entry point contract, which validates each user operation and executes them if they meet the smart contract's rules.