zkSync 如何在协议中实现帐户抽象

币圈资讯 阅读:35 2024-04-22 02:33:35 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

作者:Three Sigma,区块链审计公司 来源:X,@threesigmaxyz 翻译:善欧巴,比特币买卖交易网

集成 ZK Rollup 和账户抽象为 Layer 2 解决方案带来了可扩展性和灵活性方面的新维度。今天,我们将深入研究 zkSync 以及他们如何在协议中实现账户抽象。

什么是 zkSync

@zkSync 是由 @the_matter_labs 开发的用于以太坊上可扩展、低成本交易的去信任协议,利用 zk-rollup 技术通过批量处理链下执行的交易来缓解拥堵。 zkSync 的架构集成了 zk-rollup 和 Validium,分别定义为智能合约的 zkEVM 和链下数据可用性的 zkPorter。

在此处更深入地了解协议架构:

u7HylqSAFtMRMGv3IfIQZyTk20cmgRT7NJUr8qTP.png

什么是账户抽象

账户抽象是一项技术,通过利用智能合约作为钱包来消除对 EOA(外部拥有账户)的需求,从而提供更安全、更佳的用户体验,打造卓越的区块链体验。

在著名的 ERC-4337 AA 工作流程中,用户将操作提交到专用内存池。

捆绑者会将这些操作编译成单个交易,发送给 EntryPoint 合约,该合约会使用“validateUserOp”验证每个账户后执行这些操作。

sVCoKNNL3gBgPez362m7hBtEu0dPsvZ9WH1BJqKB.png

zkSync 如何利用账户抽象 (AA)

zkSync Era 是第一个原生实现账户抽象的 EVM 兼容链,它通过引入智能账户和支付方这两种主要组件,彻底改变了账户操作。

智能账户

智能账户由 IAccount 接口表示,该接口具有 5 种方法:

  • validateTransaction(): 检查交易是否符合账户规则。如果不符合,则会回滚。

  • executeTransaction(): 在扣除费用后运行交易。

  • payForTransaction(): 如果不使用支付方,则直接支付费用。

  • prepareForPaymaster(): 设置支付方支付费用。

  • executeTransactionFromOutside(): 允许从外部发起交易。

您可以在下面看到IACCOUNT代码

jeUYpzUdy7dPpBkwP7qgAVWcxuWrItDzDmWrcYSM.png

支付方

与 EIP4337 一样,zkSync 的账户抽象也支持支付方,支付方是可以补偿其他账户交易执行的账户。

每个支付方都应该实现 IPaymaster 接口,该接口包含以下两种方法:

  • validateAndPayForPaymasterTransaction(): 确认支付方是否同意支付交易费用并向操作员发送资金。

  • postTransaction(): 处理交易后的操作,具体取决于交易的结果和费用退款。

请参阅下面的代码:

H1Aadfm24aX8XrJZogkahVWaVu76DVBF2y8As4Hm.png

zkSync 的账户抽象 (AA) 协议与 EIP4337 非常相似,不过为了提高效率和改善用户体验,zkSync 的协议确实存在一些差异。

zkSync 的原生账户抽象与以太坊的 EIP 4337 之间的关键区别:

  1. 实现: zkSync 将 AA 集成到协议中,而 EIP4337 避免了协议级别的更改。

  2. 账户类型: zkSync 将智能合约和支付方等同对待;EIP4337 则加以区分。

  3. 交易处理: zkSync 为所有账户使用统一的内存池,不同于 EIP4337 的分离流程。

  4. 支付方: 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 拉你进入群

弹窗与图片大小一致 文章转载注明 网址:https://netpsp.com/?id=53822

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
关注我们

若遇到问题,加微信客服---清歌

搜索
排行榜
扫一扫,加我为微信好友加我为微信好友