Aptos 的 transaction.simulate.simple 真让人头大!
有时候它会莫名其妙报错,有时候又能顺利通过。
搞得我一度怀疑是合约出问题了,还是节点、钱包哪儿出问题了。
按理说,在真正执行交易前,先模拟一下是为了安全,可一旦模拟失败,整个流程就卡住走不下去。
可要是跳过模拟,心里又不踏实,万一真有大问题,没提前拦截发现,就糟了。😮💨
终于把 Web3 相关代码给整理完了~
这应该是离开 Web2 以后,最长的一次编码,接连整了好几天。
目标是解放双手和注意力,让程序能自动执行一些重复性的操作,并且做到模块化和可配置。
📝 基本分为四个部分:
1️⃣ 链上合约交互框架(包含 EVM、Aptos、Sui):框架支持多链扩展、多模块扩展、而且多模块可通过配置组合成新的流程执行任务。
2️⃣ 桌面级自动化:几年前采用的是 Autohotkey 结合浏览器的开发模式来实现对桌面的自动点击和对浏览器的精准操作,现在换到 Mac 上 AHK 已经不适用了,还好 Mac 自带 AppleScript,基本逻辑和 AHK 差不多,而且更安全。
3️⃣ 重度浏览器自动化:核心采用的是 Playwright,翻出来几年前的代码库进行修改和重构,能录制操作并生成脚本还是比较方便的。虽然,浏览器自动化非常的流水线,但还是对钱包插件的操作进行了封装。
4️⃣ 轻度浏览器自动化:使用 Tampermonkey 配合浏览器控制台脚本,如果不是因为控制台脚本无法获取一些权限(比如:访问粘贴板),油猴也基本用不到。
在实际使用上,还是 1️⃣ 和 2️⃣ 用起来最舒服,改起来快,执行起来也快。
特别是 1️⃣,在配合网络请求后可以模拟整个 dApp 的前端,全后台静默运行。
7.37K
0
The content on this page is provided by third parties. Unless otherwise stated, OKX is not the author of the cited article(s) and does not claim any copyright in the materials. The content is provided for informational purposes only and does not represent the views of OKX. It is not intended to be an endorsement of any kind and should not be considered investment advice or a solicitation to buy or sell digital assets. To the extent generative AI is utilized to provide summaries or other information, such AI generated content may be inaccurate or inconsistent. Please read the linked article for more details and information. OKX is not responsible for content hosted on third party sites. Digital asset holdings, including stablecoins and NFTs, involve a high degree of risk and can fluctuate greatly. You should carefully consider whether trading or holding digital assets is suitable for you in light of your financial condition.

