ConceptsTransactions

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.

FieldTypeDescription
senderaddressThe address of the smart contract account
nonceuint256Anti-replay protection
initCodebytesCode used to deploy the account if not yet on-chain
callDatabytesData that's passed to the sender for execution
callGasLimituint256Gas limit for execution phase
verificationGasLimituint256Gas limit for verification phase
preVerificationGasuint256Gas to compensate the bundler
maxFeePerGasuint256Similar to EIP-1559 max fee
maxPriorityFeePerGasuint256Similar to EIP-1559 priority fee
paymasterAndDatabytesPaymaster Contract address and any extra data required for verification and execution
signaturebytesUsed 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.
Edit on GitHub

Last updated on