EIP-4337
The ERC-4337 standard, also known as EIP-4337, allows developers to achieve account abstraction on the Polygon PoS. This page provides a simplified overview of
The ERC-4337 standard, also known as EIP-4337, allows developers to achieve account abstraction on the Polygon PoS. This page provides a simplified overview of the different components of ERC-4337 and how they work together.
The ERC-4337 standard consists of four main components: UserOperation, Bundler, EntryPoint, and Contract Account. Optional components include Paymasters and Aggregators.
Building ERC-4337 transactions
ERC-4337 transactions are called UserOperations to avoid confusion with the regular transaction type. UserOperations are pseudo-transaction objects that are used to execute transactions with contract accounts. ERC-4337 transactions have to be sent to nodes that include ERC-4337 bundlers.
The UserOperation object has a few fields.
| Field | Type | Description |
|---|---|---|
sender | address | The address of the smart contract account |
nonce | uint256 | Anti-replay protection |
initCode | bytes | Code used to deploy the account if not yet on-chain |
callData | bytes | Data that's passed to the sender for execution |
callGasLimit | uint256 | Gas limit for execution phase |
verificationGasLimit | uint256 | Gas limit for verification phase |
preVerificationGas | uint256 | Gas to compensate the bundler |
maxFeePerGas | uint256 | Similar to EIP-1559 max fee |
maxPriorityFeePerGas | uint256 | Similar to EIP-1559 priority fee |
paymasterAndData | bytes | Paymaster Contract address and any extra data required for verification and execution |
signature | bytes | Used to validate a UserOperation along with the nonce during verification |
ERC-4337 wallets
Users must have an ERC-4337 smart contract account to validate UserOperations. The core interface for an ERC-4337 wallet is:
interface IAccount {
function validateUserOp
(UserOperation calldata userOp, bytes32 userOpHash, address aggregator, uint256 missingAccountFunds)
external returns (uint256 sigTimeRange);
}Resources
- ERC-4337 proposal is the link to the official proposal and technical specification.
- @account-abstraction SDK is an npm package for using ERC-4337 developed by the authors of the proposal.
- Stackup provides node services with ERC-4337 bundlers and other ERC-4337 infrastructure.
- WalletKit is an all-in-one platform for adding smart, gasless wallets to your app. It has integrated support for ERC-4337 and comes with a paymaster and bundler included, requiring no extra setup.
Last updated on