我正在尝试编写一个程序,该程序将在每个步骤(执行操作代码)中显示诸如内存存储等数据。 当然,我在谈论智能合约。 就像命令“ evm --debug --code 56 run”的结果一样
在文档ethereumjs-vm中,我找到了“步骤”,我认为这就是他的工作。 https://github.com/ethereumjs/ethereumjs-vm#events 我发现一个旧的博客文章显示了如何做,但是它不再有效,并且我对Js不太了解。 https://wanderer.github.io/ethereum/nodejs/code/2014/08/12/running-contracts-with-vm/
有人知道如何将它们连接在一起,如何更正代码以向我显示此数据。还是没有人有任何可以帮助我的初学者资料?
感谢帮助。
var VM = require('ethereumjs-vm')
var vm = new VM()
var code = "7f4e616d65526567000000000000000000000000000000000000000000000000003055307f4e616d6552656700000000000000000000000000000000000000000000000000557f436f6e666967000000000000000000000000000000000000000000000000000073661005d2720d855f1d9976f88bb10c1a3398c77f5573661005d2720d855f1d9976f88bb10c1a3398c77f7f436f6e6669670000000000000000000000000000000000000000000000000000553360455560df806100c56000396000f3007f726567697374657200000000000000000000000000000000000000000000000060003514156053576020355415603257005b335415603e5760003354555b6020353360006000a233602035556020353355005b60007f756e72656769737465720000000000000000000000000000000000000000000060003514156082575033545b1560995733335460006000a2600033545560003355005b60007f6b696c6c00000000000000000000000000000000000000000000000000000000600035141560cb575060455433145b1560d25733ff5b6000355460005260206000f3"
vm.runCode(
{
code: Buffer.from(code, 'hex'),
gasLimit: Buffer.from('ffffffff', 'hex')
}, function(err, results)
{
console.log('returned: '+results.return.toString('hex'));
}
)