Core Architecture
This quickstart guide helps developers understand Account Abstraction (ERC-4337) by explaining its main components and how to use them to build applications.
Introduction
This page provides an easy-to-understand summary of ERC-4337, highlighting the main components and how they can be combined to create your own applications.
Key Components
The core components, as shown in the image below, are Users, Bundlers, EntryPoint Contracts, and Accounts.
Users start actions on Ethereum, like sending tokens or using smart contracts.
UserMemepool is where user actions (UserOps) are collected and stored until they are processed.
Bundlers take multiple user actions from the mempool, combine them into one transaction, and send it to be processed.
Entry Point Contracts check and execute the bundled transactions.
Account can do more complex things like multi-signature approvals or sponsored transactions.
Additional Components
a. Paymasters handle the gas fees needed to process transactions. They can pay these fees for users, so users don't always need to have Ether for gas.
b. Aggregator check and combine signatures for user actions, making the process more efficient and reducing the load on the network.
User Operations
User operations are crucial in our framework, used to execute actions via smart contracts. Here are the main components involved in a UserOperation:
Field | Type | Description |
---|---|---|
userAddress | address | The address of the smart account sending the JiffyOperation. |
operationNonce | uint256 | Prevents replay attacks by ensuring each operation is unique. |
deployCode | bytes | Code to deploy the userAddress if it hasn't been deployed on-chain yet. |
executionData | bytes | Data sent to the userAddress for executing the operation. |
executionGasLimit | uint256 | Maximum gas allowed for executing the operation. |
validationGasLimit | uint256 | Maximum gas allowed for validating the operation. |
initialGasFee | uint256 | Gas fee to compensate bundlers for submitting the JiffyOperation. |
maximumFeePerGas | uint256 | Similar to EIP-1559 maxFeePerGas, capping the gas fee per unit. |
maximumPriorityFeePerGas | uint256 | Similar to EIP-1559 maxPriorityFeePerGas, adding a priority fee for faster processing. |
feeManagerData | bytes | Contains the FeeManager contract address and any additional required data. |
operationSignature | bytes | Signature to validate the JiffyOperation during the verification phase. |
preExecutionConditions | bytes | Conditions that must be met before executing the operation. |
postExecutionChecks | bytes | Checks performed after execution to ensure the operation was successful. |
retryCount | uint256 | Number of times the operation can be retried in case of failure. |
callbackAddress | address | Address to call back upon completion or failure of the operation. |
metadata | string | Additional metadata or notes related to the operation. |
timestamp | uint256 | Timestamp indicating when the operation was created. |
How we are simplifying UserOps
We use three steps to confirm a transaction is successful:
- Validation: Checks that the operation is valid by verifying signatures, nonce, and other conditions
- Execution: Performs the specified action using the provided gas limits and data.
- Post-Execution: Confirms the operation was successful and manages any follow-up actions or checks.
Bundlers
Bundlers collect multiple User Operations and combine them into a single transaction. This process reduces network congestion and improves efficiency. Here's how they work:
- Collection: The Bundler gathers User Operations waiting in the mempool.
- Aggregation: It combines these operations into a single, more efficient transaction.
- Submission: The bundled transaction is sent to the blockchain network for execution.
EntryPoint Contracts
The Entry Point is a singleton smart contract that receives transactions from Bundlers, verifies, and executes UserOperations.
- Verification Process: The Entry Point contract allows the smart contract account to define its own verification and authentication methods. During verification, the Entry Point checks if the wallet has enough funds to cover the maximum possible gas usage based on the gas fields in the UserOperation. If the wallet lacks sufficient funds, the Entry Point contract rejects the transaction.
- Execution Process: During execution, the Entry Point contract performs the user operation by calling the account using the calldata specified in the UserOperation. It also transfers funds from the Smart Contract Account to reimburse the Bundler with the appropriate amount of ETH to cover the gas costs.
Paymasters
The Paymaster is an ERC-4337 defined smart contract that manages gas payment policies. These policies offer flexibility in how gas is paid (e.g., in different currencies) and by whom, eliminating the need for users to hold native blockchain tokens to interact with the blockchain.
Key Features of Paymasters:
- Flexible Currency Options: Users can pay for gas fees using any ERC20 token, such as USD Coin (USDC) or Tether (USDT), instead of the native blockchain tokens like ETH on Ethereum or MATIC on Polygon.
- Sponsoring Gas Fees: Application developers can sponsor gas fees for their users, enhancing the user experience by removing the need for users to worry about gas costs.
- Stablecoin Payments: Paymasters enable gas payments in stablecoins, providing a more stable and predictable cost structure.
- ERC-20 Token Payments: Gas fees can be paid with other ERC-20 tokens, offering greater flexibility and convenience for users.
Aggregator
An Aggregator is a smart contract that implements a signature scheme supporting aggregation. This means it can combine multiple signatures into one, making the verification process more efficient.
How Aggregators Work:
- Signature Aggregation: If multiple messages are signed with different keys, the Aggregator can generate a single combined signature. This combined signature verifies all the individual signatures.
- Calldata Cost Savings: By combining multiple signatures into one, Aggregators help save on calldata costs. This means multiple bundled UserOperations can be validated in a single step, reducing the overall transaction cost.
Key Benefits of Aggregators
- Efficiency: Aggregators make the verification process faster by handling multiple signatures at once.
- Cost-Effective: By reducing the amount of calldata needed, Aggregators lower the costs associated with processing transactions.
- Simplified Validation: Aggregators ensure that all constituent signatures are valid with a single combined signature, streamlining the validation process.