小编yis*_*wer的帖子

通过 Web3.py 在 Infura 节点获取以太坊 txpool 待处理交易的不同方式

我想通过 Web3.py 查看以太坊 txpool 中的实时待处理交易。我不运行本地节点,而是使用 Infura。

根据 Web3.py 的文档,显然一个有三个不同的选项:

  1. 使用TX 池 API
  2. 使用web3.eth.getBlock('pending')
  3. 使用web3.eth.filter('pending')

选项 1 不可行,因为 API 似乎不支持 Infura 节点。因此,我尝试了选项 2 和 3,它们给了我两组不同的待处理交易。有谁知道为什么会这样?这两种方法是否检索不同的待处理事务?谢谢!

选项2

pending_block= w3.eth.getBlock(block_identifier='pending', full_transactions=True)
pending_transactions= pending_block.['transactions']
Run Code Online (Sandbox Code Playgroud)

选项3

pending_transactions_filter= w3.eth.filter('pending')
pending_transactions= pending_transactions_filter.get_new_entries()
Run Code Online (Sandbox Code Playgroud)

python ethereum web3-donotuse

5
推荐指数
1
解决办法
4912
查看次数

标签 统计

ethereum ×1

python ×1

web3-donotuse ×1