15 请问eth,heco上如何获取某一笔交易触发的内部交易的数据

不通过API,因为API有每秒请求限制,如何直接从链上根据交易哈希获得内部交易呢?

请先 登录 后评论

最佳答案 2021-10-07 21:19

内部交易其实并不是一笔真实的交易, 而是合约之间的调用或转账,这些信息不能通过 web3 api 直接拿到, 像 etherscan 显示的内部交易,是他们使用修改过的 geth 客户端获得相信的信息,索引到数据库里。

现在 Geth 和 OpenEthereum 也提供了一些工具来获取交易内部的信息,比如 Geth 可以使用debug_traceTransaction:

var web3 = require('web3').web3;
web3.currentProvider.sendAsync({
    method: "debug_traceTransaction",
    params: ['0x3fac854179691e377fc1aa180b71a4033b6bb3bde2a7ef00bc8e78f849ad356e', {}],
    jsonrpc: "2.0",
    id: "2"
}, function (err, result) {
    ...
});

OpenEthereum 有 trace_replayTransaction

web3.currentProvider.sendAsync({
    method: "trace_replayTransaction",
    params: [desiredTransactionHash, ['trace']],
    jsonrpc: "2.0",
    id: "1"
}, function (err, out) {
    console.log(out);
}
请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 2 收藏,2568 浏览
  • carvin 提出于 2021-10-06 16:46

相似问题