Blockchain Mass Adoption with Account Abstraction ERC 4337 [2]

Khang Vu Tien
5 min readJul 31, 2023

--

In a previous article we explained simply what is the main pain in owning cryptos and how Account Abstraction (ERC-4337) solves the pain. https://kvutien-yes.medium.com/blockchain-mass-adoption-with-account-abstraction-erc-4337-1-ae13b84ea81f

In this article, we follow-up and explain 2 major implementation details: (1) how the “wallet” smart contract recognizes transactions belonging to its human avatar, and (2) how to on-board in the blockchain a layperson who has no private key and no virtual currency to pay the on-boarding.

Reminder of the pain

  1. To do blockchain transaction, a person needs to sign the transaction
  2. To sign, the person needs a cryptographic key of 256 bits. Quite complicated process to generate and to keep.
  3. If the key is lost, the totality of funds controlled by this key is lost.

Reminder of the solution

  1. A “user” is represented on the blockchain by a smart contract called a “wallet” that contains what the user owns and sends out blockchain transactions when asked to do so.
  2. The user broadcasts a “user operation”, a descriptor of a transaction. This descriptor is stored by the Internet on several distributed copies of a “memory pool”.
  3. A “bundler” picks a user operation, validates that the operations are blockchain-compliant, signs it with their private key, calls the smart contract of the descriptor (the avatar of the user) to send the signed transaction. The bundler receives a fee for this.

Strong point: ERC-4337 is agnostic of business logic

The ERC-4337 is agnostic to what kind of business logic a “wallet” implements.

For example, the “wallet” can execute a variety of financial functions between a user and a bank or an insurance. It can also execute project management tasks between a member and the rest of a team. It can trigger barter operations based on confirmation of “n-among m” persons. It can accept a new member in a restricted golf club based on approval of a number of club’s board trustees. The types of applications are limitless.

The ERC-4337 is agnostic to how the parties involved in the smart contract “wallet” identify themselves. Some users simply require their avatars to recognize a mobile phone identification number (MIN) while some may require multiple signatures using different signing protocols, different from the blockchain ECDSA signature.

How the avatar recognizes its associated user

In Machu Picchu, the person-in-need will be onboarded by a field staff of an NGO, or by the chief of village, or by a local representative of a government agency etc. There will be one “wallet” per logic of the helper entities.

For example, Ms. Aminatou Bouaré in Niger may have one “wallet” from UNICEF, one from Red Cross, one from the World Food Program, one from the National agriculture agency etc. and still doesn’t see any difference. All she knows is her cellular phone.

Once deployed, the person-in-need will be interrogated regularly by SMS by her helper sponsor (an NGO field staff, her chief of village etc.) to update the data of this person. In this doing, the MIN number of the cellular phone of this person will be mixed with the signature of the helper person (“1-among-n” signature) to authenticate the transaction.

What have we achieved?

Let’s remind that the initial objective is to let laypersons to do trustless blockchain transactions without owing a private key, without even having “coins” to pay the transaction fees and without knowing that a blockchain is used. To achieve this:

  • A layperson is represented by a smart contract (a kind of blockchain avatar) that executes the blockchain logic on behalf of this layperson.
  • Instead of sending a signed transaction, the layperson broadcasts a descriptor of the transaction requested, a “User Operation”.
  • Any “bundler” can pick any “user operation”, validate that it is blockchain-compliant, sign it with a private key and call the layperson “avatar” to send the transaction to the blockchain. The bundler gets paid a small fee for it.
  • How the avatar recognizes the layperson as its counterpart is left to the application, and many solutions already exist, including using simple cellular phones.

But, if we keep the objective that the layperson owns no cryptos and knows nothing about blockchain, the question still remains “who pays the bundler fees, the transaction fees and with which money”?

Introducing the “paymaster”

In the Account Abstraction infrastructure as defined, it becomes simple to add someone who pays the fees for the layperson.

  • If the layperson doesn’t wish to pay the operation, the User Operation descriptor may contain the address of a “paymaster” who will pay on behalf of the layperson.

The Entry Point first calls `validateOp()` of the “wallet” smart contract specified in the User Operation descriptor.

  • Once the operation in the descriptor validated, if the descriptor has a paymaster address, the Entry Points calls the function `validatePaymasterOp()` of that paymaster, who decides whether to pay or not this operation and eventually pays.
  • Any User Operation which fails either validation is discarded.
  • If both validations succeed, the Entry Point calls the function `executeOp()` of the op’s sender “wallet” smart contract, tracking how much gas is used, then transfer ETH to the bundler to pay for that gas.
Sequence diagram how a Paymaster is involved

Mission accomplished

  • The layperson needs to know nothing about private keys, knows only their mobile phone, itself known at construction by the avatar smart contract.
  • The layperson needs to know nothing about blockchain operation. The bundler signs and calls the avatar smart contract.
  • The layperson needs no coins to start being on-boarded and use blockchain operations. The paymaster pays, using any kind of crypto or token or Central Bank Digital Currency, as agreed with the avatar smart contract.
  • Once on-boarded, the layperson keeps custody of their money in the “wallet”, the avatar smart contract.
  • When multi-signature is used, “witnesses” can help recover the avatar smart contract if a layperson loses the mobile phone.

Further readings

There are 3 papers that are useful to understand more in detail how to implement Account Abstraction. The papers progress from simple to complex:

  1. A blog article written by Alchemy. It explains how Account Abstraction works by reasoning with the reader how to design a solution to the needs. It ends up with something that is not ERTC-4337 but is very similar. https://www.alchemy.com/blog/account-abstraction .
  2. The components in Account Abstraction as explained to developers, written by Eden Network who has deployed a bundler and an EntryPoint directly useable on the Goerli testnet by developers: https://docs.edennetwork.io/eden-bundler/erc4337-overview/.
  3. The text of the Account Abstraction standard ERC 4337, first introduced on October 8, 2021. https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4337.md.
  4. The audit report of OpenZeppelin who was asked to independently audit the implementation. https://blog.openzeppelin.com/eth-foundation-account-abstraction-audit .

Finally, there is a start-up named Stackup ( https://stackup.sh/ ) that provides pre-built ERC-4337 infrastructure. It targets blockchain service providers who want to leverage ERC-4337 to make their own clients use blockchain services without being themselves ETH owners. They have an interesting github: https://github.com/stackup-wallet .

--

--

Khang Vu Tien
Khang Vu Tien

Written by Khang Vu Tien

Machu Picchu — Data as a Public Service

Responses (1)