更新!我用geth --rpcapi txpool --rpc运行我的节点
var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545')); console.log(web3.txpool);
我仍然收到
undefined使用
web3.eth.extend({ property: 'txpool', methods: [{
name: 'content',
call: 'txpool_content' },{
name: 'inspect',
call: 'txpool_inspect' },{
name: 'status',
call: 'txpool_status' }] });
web3.eth.txpool.content().then(console.log).catch(console.error)我仍然只得到{ pending: '0x0', queued: '0x0' }
这怎么可能呢?我以为会有上百笔交易。
发布于 2018-06-29 20:18:48
当您运行您的节点时,您必须使用--rpcapi txpool。
发布于 2018-06-29 21:21:33
web3.py文档(用于与Python连接)对于web3.js文档(用于与JavaScript连接)不可互换。它们有不同的API。
Web3.js似乎没有一个用于查询事务池的内置机制(可能是因为geth和奇偶校验方法不同)。请参见添加您自己的池API:如何访问web3脚本中的txpool?的答案。
https://ethereum.stackexchange.com/questions/52388
复制相似问题