调试合约 原文地址
truffle整合了debug功能,方便调试合约,跟传统的应用程序的断点调试很相似
但是truffle的调试的时机跟传统软件有很大的区别,传统软件的调试是实时的run-time,而truffle的调试是跟合约程序的运行时分离的,你不能够在合约执行的时候调试,也就是说合约的执行不能被调试打断,但是因为合约的transaction操作会返回一个hash值,所以可以根据这个hash值来调试。
另外这个调试几个条件:
- Truffle 4.0 or above. v4.0+的truffle版本
- The hash of a transaction on your desired blockchain. 你的目标操作的hash值
- The source code and artifacts the transaction encounters.合约的源码和编译后的文件
不用担心因为transaction执行失败而无法调试,因为这个执行状态依然会被保留在blockchain上
调试使用终端:
如果hash正确,后面会打印以下信息:
- A list of addresses either transacted against or created during the course of this transaction.打印一张列表:在合约的进程中涉及此transaction操作的所有address的列表
- A list of available commands for using the de