{"content":{"title":"超实用工具分享-tenderly：超强debug、模拟分析工具","body":"# tenderly工具使用\r\n- 先上工具**链接**：[https://dashboard.tenderly.co/](https://dashboard.tenderly.co/)\r\n\r\n\r\n## 前言\r\n有没有遇见过像这样**头疼的场景**：\r\n1. **交易失败了**，浏览器上只报了个“Failed”；大哥我也知道交易失败了，好歹告诉我下原因吧，但是浏览器上只是个冷冰冰的“Failed”,留下懵逼的我百思不得其解，默默的进行合约代码走读。\r\n\r\n    ![image.png](https://img.learnblockchain.cn/attachments/2022/11/lKDsCZUB6366425d5910b.png!/scale/50)\r\n2.我想进行主网**测试这笔交易**到底成不成，但是又怕失败浪费手续费，或者心疼其他代币消耗，不想进行真实的交易，像这样的交易肯定是要慎重的，毕竟手续费不退：\r\n\r\n    ![image.png](https://img.learnblockchain.cn/attachments/2022/11/5PpsFh53637b5b925e7ee.png)\r\n3. 想学习**梳理优秀的开源项目代码**，想理清楚整个项目的运行原理，但是由于智能合约debug的困难性，暂时只知道在remix上可以debug，但是由于操作的繁琐我放弃了\r\n \r\n \r\n ## **工具介绍**\r\n 优秀的模拟、测试工具，排查问题好手段\r\n 官网：[https://tenderly.co/](https://tenderly.co/)\r\n \r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/DhYbGf8n63664cf2d3f52.png!/scale/50)\r\n \r\n \r\n \r\n                   \r\n       \r\n\r\n\r\n\r\n## **使用场景一：分析失败交易**\r\n### 复制待分析交易的交易hash：\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/hkl04zFL63664808e4262.png!/scale/50)\r\n\r\n### 粘贴上面复制的交易hash：\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/bdybtKn6636648557f766.png!/scale/50)\r\n\r\n### 点击进入\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/cFRRk6dl636648a46eea7.png!/scale/50)\r\n\r\n### 具体原因\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/d9mb1Ngb636649e819120.png!/scale/50)\r\n\r\n### debug\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/5V6YLAJ763664a2e321bf.png!/scale/50)\r\n\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/LRP8rZne63664aab6556c.png!/scale/50)\r\n\r\n\r\n### 交易涉及的合约\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/yf2KSS1V63664adce411e.png!/scale/50)\r\n\r\n\r\n### 链上数据状态变化\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/OefD8ljK63664b1a201ce.png!/scale/50)\r\n\r\n### 交易产生的事件\r\n\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/pzulHLlg63664b641c5ad.png!/scale/50)\r\n\r\n\r\n## **使用场景二：模拟交易**\r\n### tenderly模拟功能界面:点击进入\r\n\r\n\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/TBltedpS63664d9b2d7ef.png!/scale/50)\r\n\r\n### **复制数据**\r\n#### 复制与小狐狸交互的合约：填至后面的NO.1\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/TMMyq0Ch637b5b08e1366.png)\r\n\r\n---\r\n\r\n#### 复制交易数据：填至后面的NO.2\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/QctpkL1z637b5b30a80a2.png)\r\n\r\n---\r\n\r\n\r\n#### 复制交易发起人：填至后面的NO.3\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/KO9C7KGO637b5b5be46e5.png)\r\n\r\n---\r\n\r\n\r\n\r\n\r\n### 将上面从小狐狸中复制的数据填至下面的空位，选择好你现在交易的网络\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/L6hOyUvO636646180a31c.png!/scale/50)\r\n\r\n### 点击模拟交易\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/Wy9Z7SJt6383470db04aa.png)\r\n\r\n\r\n\r\n### 模拟结果\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/Lt0hS3rj636647e53bee4.png!/scale/50)\r\n\r\n\r\n### 同上分析交易，可以进行debug看具体调用链路和数据进行分析\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/TY6woZED6366478bbdbc8.png!/scale/50)\r\n\r\n## **使用场景三：自主添加线上合约模拟交易**\r\n- 这个其实就是一个fork主网模拟测试操作，功能同之前介绍的一篇文章：[hardhat框架实战-超强fork主网数据合约测试](https://learnblockchain.cn/article/4958)；只不过这个做了操作界面，不用写测试脚本也可以使用fork主网来进行模拟测试功能，方便了用户的使用\r\n\r\n### 添加线上合约\r\n- 注意这边合约必须是已经开源了的，才可以使用这个功能\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/ro5qcC4D63834916161c9.png)\r\n\r\n填写好对应的线上合约地址以及对应网络，对合约起一个别名\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/wzVwey3r638349cb69cab.png)\r\n\r\n### 添加模拟的用户地址\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/PjvqvNj863834a0bf101a.png)\r\n\r\n填写模拟的账户地址，选择对应网络\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/ZQUOKnct63834b0e15d9b.png)\r\n\r\n### 使用刚添加的账户调用添加的合约模拟交易\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/3k47Hn9563834c7ad35df.png)\r\n\r\n选择合约，填入参数，选择模拟用户\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/MPz3a5De63834d38a2a73.png)\r\n\r\n### 模拟结果\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/GzniyaEH63834de98b198.png)\r\n\r\n### 同上分析交易，可以进行debug看具体调用链路和数据进行分析\r\n\r\n![image.png](https://img.learnblockchain.cn/attachments/2022/11/AGwnZb4F63834e675ba26.png)\r\n\r\n\r\n\r\n## 小结\r\ntenderly工具真的非常强大，操作又十分简单，不管对于开发人员来说，还是对于用户来说都是非常实用的！\r\n\r\n## 参考\r\n**当然是YouTube拉**\r\n\r\n参考1：[https://www.youtube.com/watch?v=3zFe5MNBf1g](https://www.youtube.com/watch?v=3zFe5MNBf1g)\r\n参考2：[https://www.youtube.com/watch?v=90GN9Ut8LhU](https://www.youtube.com/watch?v=90GN9Ut8LhU)"},"author":{"user":"https://learnblockchain.cn/people/11497","address":null},"history":"QmPdKu5aDK13ZU73JJ9ecS63AekanEPx1BBnNHg64tdqN1","timestamp":1669549680,"version":1}