【问题标题】:web3.py isConnected() function with testnet带有测试网的 web3.py isConnected() 函数
【发布时间】:2019-02-13 17:51:13
【问题描述】:

我正在用 Python 开发一个应用程序来处理一些 Ether。我已经安装了 geth 和 web3.py 并且确实对 isConnected() 的不同行为有问题。

Geth:geth-alltools-darwin-amd64-1.8.15-89451f7c(最新)

web3.py:4.6.0(最新)

Python:3.7

Mac OS X

我是这样开始 geth 的:

./geth --syncmode=light --cache=1024 --maxpeers=12
./geth --testnet console

示例代码:

from web3.auto import w3
if (w3.isConnected()):
    print("I am connected")
else:
    print("I am not connected")

只要我使用主网,isConnected() 的行为就符合预期。如果 testnet isConnected() 总是 False,即使链是完全同步的!

知道我做错了什么吗?

【问题讨论】:

    标签: python web3 geth


    【解决方案1】:

    您需要将主网的 url 更改为任何测试网

    【讨论】:

      猜你喜欢
      • 2018-09-19
      • 2020-03-23
      • 2022-12-10
      • 2022-01-03
      • 2019-12-26
      • 2021-08-04
      • 2020-11-26
      • 2022-07-15
      • 2021-12-17
      相关资源
      最近更新 更多