0%
Overview page background
HomeOverviewsAccount Abstraction
How do ERC-4337 smart contract wallets work?

How do ERC-4337 smart contract wallets work?

Brady Werkheiser headshot

Written by Brady Werkheiser

Logan Ross headshot

Reviewed by Logan Ross

Published on February 5, 20243 min read

Smart contract wallets that use Account Abstraction (ERC-4337) create a wallet that is managed using a smart contract instead of a wallet that is managed by a single private key like EOA wallets (Externally Owned Address).

The programmable nature of smart contract wallets allows for the development of a wide range of new use cases. By reducing complexity without compromising security or anonymity, smart contract wallets will help facilitate onboarding of the next wave of blockchain users.

Want to add embedded smart contract wallets to your app? Use our enterprise-grade Embedded Accounts and vertically integrated AA infrastructure to onboard users with no seed phrases, gas, or friction.

Smart contract wallets store and manage digital assets (e.g. cryptocurrency, NFTs, etc.) using smart contracts. Smart contract wallets are the foundation of account abstraction: the process of unifying the various Ethereum account types into a single type by ‘abstracting’ an account’s control away from the network and defining it with a smart contract.

Some examples of smart contract wallets that use ERC-4337:

  1. Soul Wallet

  2. Candide

  3. UniPass

  4. Castle

  5. Openfort

Two main smart contract wallets that don't use ERC-4337 are Safe and Argent.

Also known as smart contracts, contract accounts contain code which manages the exchange of information between parties. Contract accounts are used in every DeFi protocol, NFT collection, or ERC-20 token.

All of the contract's business logic and state variables are stored on-chain. Because the state and code of a smart contract is stored on-chain, the externally-owned account deploying it must pay a fee.

Note: In web3 programming, there is a ‘smart contract factory’ pattern, where a contract can deploy other contracts via a predefined interface. Even in this case, the transaction initiating it must originate with and be paid for by an EOA.

The main difference between smart contract accounts and EOA accounts is that smart contract accounts can contain logic. Because only EOA accounts can initiate transactions smart contract accounts rely on Bundlers' EOA account to bundle user operations into a single transaction that is posted on the blockchain.

Under current Ethereum protocol, EOAs are the only account type that can initiate a transaction, whether it’s a contract call or a value transfer. Even in the case of a contract account calling another contract account, the origin of the transaction always comes from an externally-owned account. 

Here's a comparison of contract accounts and EOA accounts:

Chart comparing the differences between EOA wallets and smart contract wallets.
Chart comparing the differences between EOA wallets and smart contract wallets.

So how do smart contract wallets execute transactions if they can't initiate transactions on their own?

Because Smart Contract wallets can not initiate a transaction, they must be called by an EOA wallet. This process is supported by multiple Account Abstraction infrastructure providers (e.g. Bundlers) and smart contracts (e.g. EntryPoint)

The typical flow of a smart contract wallet transaction is:

  1. A user wants to execute a UserOperation

  2. UserOperations are sent to an "alternative mempool"

  3. A Bundler with an EOA wallet bundles and sends all of the UserOperations to the EntryPoint contract

  4. The EntryPoint contract validates and executes all of the UserOperations

  5. The EOA wallet that bundled the UserOperations is repaid the ETH they spent on behalf of the users by the users' wallets or the Paymaster

Diagram showing how UserOps are bundled, validated, and executed.
Diagram showing how UserOps are bundled, validated, and executed.

While understanding how smart contract wallets work from a technical perspective may be difficult to understand, for end users, smart contract wallets provide many improvements compared to EOA wallets such as programmability and the ability for features like social recovery.

For more information on how each component of Account Abstraction works read our series, "You Could Have Invented Account Abstraction," which was written by David Philipson, on Alchemy's Account Abstraction Infrastructure engineering team.

  1. UserOps, Bundlers, and the EntryPoint Contract

  2. Sponsoring Gas Using Paymasters

  3. Creating Smart Contract Wallets

  4. Aggregating Signatures

Overview cards background graphic
Section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key