Author: Three Sigma, blockchain audit company Source: X, @threesigmaxyz Translation: Shan Ouba, Golden Finance
Integrating ZK Rollup and account abstraction brings a new dimension of scalability and flexibility to Layer 2 solutions. Today we’ll take a deep dive into zkSync and how they implement account abstraction within the protocol.
What is zkSync
@zkSync is developed by @the_matter_labs for Ethereum A scalable, trustless protocol for low-cost transactions that leverages zk-rollup technology to alleviate congestion by batching transactions executed off-chain.
The architecture of zkSync integrates zk-rollup and Validium, respectively defined as zkEVM for smart contracts and zkPorter for off-chain data availability.
Learn more about the protocol architecture here:
What is account abstraction
Account abstraction is a technology that eliminates the need for EOA (externally owned accounts) by utilizing smart contracts as wallets, thereby providing a safer and better user experience, creating Excellent blockchain experience.
In the well-known ERC-4337 AA workflow, users submit operations to a dedicated memory pool.
The bundler will compile these operations into a single transaction and send it to the EntryPoint contract, which will perform these operations after validating each account using "validateUserOp".
p>
How zkSync utilizes account abstraction (AA)
zkSync Era is the first native implementation of account abstraction EVM-compatible chain, which revolutionizes account operations by introducing two main components: smart accounts and payers.
Smart account
Smart account is represented by the IAccount interface, which has 5 methods:
validateTransaction(): Check whether the transaction complies with the account rules. If not, it will be rolled back.
executeTransaction(): Run the transaction after deducting the fee.
payForTransaction(): If the payer is not used, the fee is paid directly.
prepareForPaymaster(): Set the payer to pay the fee.
executeTransactionFromOutside(): Allows transactions to be initiated from outside.
You can see the IACCOUNT code below
< img src="https://img.jinse.cn/7204205_watermarknone.png" title="7204205" alt="jeUYpzUdy7dPpBkwP7qgAVWcxuWrItDzDmWrcYSM.png">
Payer
Like EIP4337, zkSync's account abstraction also supports payers, which are accounts that can compensate other accounts for transaction execution.
Each payer should implement the IPaymaster interface, which contains the following two methods:
validateAndPayForPaymasterTransaction(): Confirms whether the payer agrees to pay the transaction fee and send funds to the operator.
postTransaction(): Handles post-transaction actions, depending on the outcome of the transaction and fee refund.
See the code below:
zkSync's account abstraction (AA) protocol is very similar to EIP4337, but zkSync's protocol does have some differences to improve efficiency and user experience.
Key differences between zkSync's native account abstraction and Ethereum's EIP 4337:
Implementation: zkSync integrates AA into the protocol, while EIP4337 avoids protocol-level changes.
Account type: zkSync treats smart contracts and payers equally; EIP4337 distinguishes them.
Transaction processing: zkSync uses a unified memory pool for all accounts, which is different from the separation process of EIP4337.
Payer: zkSync supports payers for all accounts, while EIP4337 limits it to smart contracts.
How to create a smart account on zkSync
To To create a smart account on zkSync, please use IAccount to implement basic methods, and use IPaymaster to implement payer-dependent fee payments.
It is also useful to ensure that your account supports EIP-1271 for signature verification.
After completing these steps, just deploy your account using zkSync's createAccount method!
zkSync currently integrates 2 smart contract wallets:
✦ HoldstationW
✦ pier_wallet