我运行了一个testnet (恢复) ethereum节点。我想了解txpool的内容。使用geth控制台,我可以访问变量txpool。
我的问题是如何在web3脚本中访问这个变量?
Web3 = require("web3");
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));如下所示:
pendingTx = web3.txpool ?
pendingTx = web3.eth.txpool ?它们都是未定义的..。
发布于 2018-05-07 13:21:20
使用Web3 1.0.0,很容易自己实现它:
var Web3 = require('web3');
var web3 = new Web3('ws://127.0.0.1:8546');
web3.eth.extend({
property: 'txpool',
methods: [{
name: 'content',
call: 'txpool_content'
},{
name: 'inspect',
call: 'txpool_inspect'
},{
name: 'status',
call: 'txpool_status'
}]
});然后正常使用:
web3.eth.txpool.status().then(console.log).catch(console.error)输出:
{pending: "0x0", queued: "0x0"}https://ethereum.stackexchange.com/questions/24127
复制相似问题