Book a free call

How to Implement Account Abstraction Step by Step

Account abstraction turns a wallet into a programmable smart contract account. Here is how to add it to your app, from choosing an approach to launch.

Hertiv engineering teamReviewed by a senior engineer
6 min read
How to Implement Account Abstraction Step by Step
On this page

Short answer

Account abstraction lets a wallet behave like a smart contract account instead of a single private key, so it can recover access, pay gas in tokens, batch actions and set spending rules. To implement it, pick an approach such as ERC-4337 or native account abstraction, deploy or connect a smart contract account, add a bundler and paymaster, then test recovery, gas sponsorship and limits before launch.

What is account abstraction?

Account abstraction is a way to make a blockchain account a smart contract instead of a single private key, so the account itself can hold the rules for how transactions are signed, paid for and approved. In the older model, an externally owned account is controlled by one key: lose the key and you lose the account, and every transaction must be paid for in the chain's native token.

With account abstraction, the account is code. That code can check a signature from more than one key, accept a session key that only works for one app, or let a third party pay the gas fee. The user still owns the account, but the rules for using it are written into the account itself rather than decided by the wallet app alone.

The idea matters because key loss and gas fees are the two biggest reasons new users give up on wallets. A smart contract account can offer recovery through trusted contacts, let a new user start without buying tokens first, and batch several actions into one signed step. Those features are what make account abstraction worth building for consumer apps.

What changes for users when accounts become smart?

The main change for users is that the account gains features a plain key-based account cannot offer. The table below compares the two models on the points users notice first.

Feature Key-based account Smart contract account
Key control One private key Several keys, social recovery, session keys
If a key is lost The account is lost Recovery through guardians or a backup key
Gas payment Native token only Native token, stablecoin, or a sponsor
Actions per signature One action Several actions batched into one
Spending rules None built in Daily limits and per-app permissions

None of this removes the need for good key hygiene. A smart contract account is still only as safe as its code and its recovery setup, and a badly written account contract can lock funds or let an attacker in. The extra features are useful only when the code behind them has been reviewed and tested, which is why the best account abstraction wallets for enterprises all start from reviewed account implementations.

Which account abstraction approach should you pick?

There are three common approaches, and the right one depends on your chain, your timeline and how much control you need over the account code.

  • ERC-4337. Works on chains that support it without changing the protocol. Accounts are smart contracts, and a separate bundler network submits UserOperations. Best when you want to ship on Ethereum or an EVM chain today.
  • Native account abstraction. Built into the chain itself, so accounts are smart contracts by default. Best when you are building on a chain that already supports it and you want the simplest model.
  • Embedded wallets. A provider hosts the account logic and key management behind your app's sign-in. Best when you want the fastest launch and are willing to trust a provider with part of the flow.

For most teams, ERC-4337 is the practical starting point because it works on the chains your users already hold assets on, and the tooling around bundlers and paymasters is the most mature.

Native abstraction is cleaner when your chain supports it, but it ties you to that chain. Embedded wallets are the fastest route, but check what the provider controls before you commit, and compare the account model with how to implement a multisig wallet if shared control is part of your plan.

How to implement account abstraction, step by step

Implementation follows a fixed order: flows first, then the account contract, then the infrastructure around it. Skipping the flow design is how teams end up with an account that works in a demo and confuses real users.

  1. Define the user flows first. Write down exactly what a new user does in the first five minutes: sign-up, recovery, gas payment and spending limits.
  2. Pick your approach and chain. Choose ERC-4337 on your target chain, native abstraction, or an embedded wallet provider.
  3. Choose or write the account contract. Use a reviewed account implementation rather than writing one from scratch, and keep any custom logic small.
  4. Set up a bundler. Run your own or use a bundler service so UserOperations reach the chain reliably.
  5. Add a paymaster. Decide which transactions you sponsor, set spending caps per user and per day, and fund the paymaster with a clear budget.
  6. Build the recovery path. Add guardians or a backup key, test recovery on a test network, and write the recovery steps into your help pages.
  7. Audit, test and launch in stages. Get the account contract audited, test with a small group, then open access gradually while watching gas spend and failed operations.

Each step has a clear exit test. Do not move to the next step until the current one works on a test network with real user flows, not just a single happy-path transaction.

How paymasters and gas sponsorship work

A paymaster is a contract that agrees to pay the gas fee for a user's operation when certain conditions are met. The user signs an operation that says what they want to do, and the paymaster checks the rules — for example, that the user is within a daily limit — then pays the fee and the operation is executed.

Sponsorship changes the maths of onboarding: a new user can try the app without buying the chain's token first. That is useful, but it also creates a bill you must control. Set a cap per user and per day, watch spend daily, and pause sponsorship if a single address starts burning through the budget. A paymaster without caps is an open tap.

The team that builds the wallet should own that budget, as any crypto wallet development plan should state up front.

You can also let users pay gas in a token they already hold, such as a stablecoin. The paymaster accepts the token, holds it or converts it, and pays the chain fee itself. This keeps the flow simple for users who hold stablecoins but not the chain's native token.

Example (hypothetical): a wallet app adds account abstraction

Example (hypothetical): a small wallet app with 2,000 monthly users wants new users to start without buying tokens. The team picks ERC-4337, uses a reviewed account implementation, and adds a paymaster that sponsors the first three transactions for each new user, capped at 50 sponsored transactions a day.

The maths is simple. If 40 new users arrive each day and each uses two sponsored transactions, that is 80 sponsored operations a day, above the 50 cap — so the team raises the cap to 100 and budgets for it. At a planning figure of $0.10 per operation, 100 operations a day cost $10 a day, or about $300 a month.

The team also adds social recovery with two guardians, and tests recovery twice on a test network before launch.

After launch, the team watches two numbers every day: sponsored operations and failed operations. If failures climb, they pause new sign-ups and check the bundler before users notice. The launch stays small until both numbers are steady for two weeks.

What are the common mistakes?

The most common account abstraction mistakes are writing custom account code, skipping the audit, and launching gas sponsorship without limits.

  • Writing a custom account contract instead of using a reviewed implementation.
  • Skipping the audit because the account logic looks simple.
  • Launching a paymaster without daily caps, then finding the gas bill.
  • Testing recovery only once, on a test network, and never again.
  • Giving session keys more permission than the app needs.
  • Hiding the recovery steps from users until they lose access.

Key takeaways

  • Account abstraction turns a wallet into a smart contract account with programmable rules
  • Recovery, gas sponsorship and batched actions are the features users notice first
  • ERC-4337 is the practical starting point on EVM chains; native abstraction is cleaner where supported
  • A paymaster needs daily caps and monitoring, or gas spend runs away
  • Use a reviewed account implementation and audit it before launch

Frequently asked questions

Does account abstraction remove private keys?

No. Keys still sign transactions, but the account contract decides which keys count and what each key can do. A lost key can be replaced through recovery instead of losing the account, which is the main difference from a plain key-based account.

Is ERC-4337 the same as account abstraction?

No. Account abstraction is the general idea of making accounts programmable, and ERC-4337 is one standard that brings it to Ethereum and EVM chains without changing the protocol. Some chains build account abstraction in natively instead.

Can users pay gas in stablecoins?

Yes, through a paymaster. The paymaster accepts a stablecoin or another token from the user and pays the chain fee in the native token. The user never needs to hold the native token, which removes a common onboarding blocker.

What is a bundler?

A bundler collects UserOperations from many users, packs them into one on-chain transaction and submits it. Without a bundler, each UserOperation would need its own submission path, so the bundler is what makes ERC-4337 work in practice.

Is account abstraction safe?

It can be, when the account contract is reviewed and audited and the recovery path is tested. The risk moves from key loss to contract bugs, so the audit and the recovery setup matter more than they do for a plain key-based wallet.

Do I need account abstraction for a simple wallet?

Not always. A simple wallet that holds assets for experienced users works fine with plain keys. Account abstraction pays off when you serve new users, need recovery, or want to sponsor gas and batch actions.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning account abstraction for your wallet or app? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Crypto Wallet service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call