zkSync 如何在协议中实现帐户抽象
作者:Three Sigma,区块链审计公司 来源:X,@threesigmaxyz 翻译:善欧巴,比特币买卖交易网
集成 ZK Rollup 和账户抽象为 Layer 2 解决方案带来了可扩展性和灵活性方面的新维度。今天,我们将深入研究 zkSync 以及他们如何在协议中实现账户抽象。
什么是 zkSync
@zkSync 是由 @the_matter_labs 开发的用于以太坊上可扩展、低成本交易的去信任协议,利用 zk-rollup 技术通过批量处理链下执行的交易来缓解拥堵。 zkSync 的架构集成了 zk-rollup 和 Validium,分别定义为智能合约的 zkEVM 和链下数据可用性的 zkPorter。
在此处更深入地了解协议架构:
什么是账户抽象
账户抽象是一项技术,通过利用智能合约作为钱包来消除对 EOA(外部拥有账户)的需求,从而提供更安全、更佳的用户体验,打造卓越的区块链体验。
在著名的 ERC-4337 AA 工作流程中,用户将操作提交到专用内存池。
捆绑者会将这些操作编译成单个交易,发送给 EntryPoint 合约,该合约会使用“validateUserOp”验证每个账户后执行这些操作。
zkSync 如何利用账户抽象 (AA)
zkSync Era 是第一个原生实现账户抽象的 EVM 兼容链,它通过引入智能账户和支付方这两种主要组件,彻底改变了账户操作。
智能账户
智能账户由 IAccount 接口表示,该接口具有 5 种方法:
validateTransaction(): 检查交易是否符合账户规则。如果不符合,则会回滚。
executeTransaction(): 在扣除费用后运行交易。
payForTransaction(): 如果不使用支付方,则直接支付费用。
prepareForPaymaster(): 设置支付方支付费用。
executeTransactionFromOutside(): 允许从外部发起交易。
您可以在下面看到IACCOUNT代码
支付方
与 EIP4337 一样,zkSync 的账户抽象也支持支付方,支付方是可以补偿其他账户交易执行的账户。
每个支付方都应该实现 IPaymaster 接口,该接口包含以下两种方法:
validateAndPayForPaymasterTransaction(): 确认支付方是否同意支付交易费用并向操作员发送资金。
postTransaction(): 处理交易后的操作,具体取决于交易的结果和费用退款。
请参阅下面的代码:
zkSync 的账户抽象 (AA) 协议与 EIP4337 非常相似,不过为了提高效率和改善用户体验,zkSync 的协议确实存在一些差异。
zkSync 的原生账户抽象与以太坊的 EIP 4337 之间的关键区别:
实现: zkSync 将 AA 集成到协议中,而 EIP4337 避免了协议级别的更改。
账户类型: zkSync 将智能合约和支付方等同对待;EIP4337 则加以区分。
交易处理: zkSync 为所有账户使用统一的内存池,不同于 EIP4337 的分离流程。
支付方: zkSync 支持所有账户的支付方,EIP4337 则将其限制为智能合约。
如何在 zkSync 上创建智能账户
要在 zkSync 上创建智能账户,请使用 IAccount 实现基本方法,并使用 IPaymaster 实现依赖支付方的费用支付。
确保您的账户支持 EIP-1271 进行签名验证也非常有用。
完成这些步骤后,只需使用 zkSync 的 createAccount 方法部署您的账户即可!
zkSync 目前集成有 2 个智能合约钱包:
✦ HoldstationW
✦ pier_wallet
The integration and account abstraction of Shanouba Bitcoin trading network have brought new dimensions of scalability and flexibility to the solution. Today, we will study in depth how they realize account abstraction in the protocol. What is the untrusted protocol developed for scalable low-cost transactions on the Ethernet workshop? The architecture integrated and defined as smart contract and offline data respectively uses technology to relieve congestion by batch processing transactions executed under the chain. Learn more about the protocol architecture here. What is account abstraction? Account abstraction is a technology that eliminates the need for external accounts by using smart contracts as wallets, thus providing a safer and better user experience and creating an excellent blockchain experience. In the famous workflow, users submit operations to a dedicated memory pool, and the binder will compile these operations into a single transaction and send them to the contract. The contract will use the verification of each account and then perform these operations. How to use account abstraction? It is the first compatible chain that natively realizes account abstraction. It completely changes the account operation by introducing two main components, namely, smart account and payer. Smart account is represented by an interface. This interface has a method to check whether the transaction conforms to the account rules. If it does not conform, it will roll back and run the transaction after deducting the fees. If you don't use the payer, you can directly pay the fees and set the payer to pay the fees. You can see the code below. The payer is the same as the account abstraction. It is also supported that the payer is an account that can compensate for the transaction execution of other accounts. Each payer should implement an interface. This interface includes the following two methods to confirm whether the payer agrees to pay the transaction fee and send funds to the operator to handle the operation after the transaction, which depends on the transaction result and fee refund. Please refer to the account abstraction protocol in the code below, which is very similar to the protocol in order to improve efficiency and user experience. The key difference between the realization of the workshop will be integrated into the agreement, avoiding the change of the agreement level. It is also very useful to treat the smart contract and the payer equally, and then distinguish the transaction processing. The payer supports the separation process of all accounts, while the payer limits it to the smart contract. How to create a smart account on the Internet? Please use the basic method of realization and use the fee payment that depends on the payer to ensure that your account supports signature verification. After completing these steps, you can deploy your account by the method you use, and now you can integrate a smart contract wallet. 比特币今日价格行情网_okx交易所app_永续合约_比特币怎么买卖交易_虚拟币交易所平台
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。