Ethereumjs

AttributeError:“Web3”沒有屬性“shh”

  • July 23, 2018

Web3.py 版本:4.2.1 Python:3.5.2 作業系統:linux geth 版本:1.8.0-unstable

我正在使用 –shh 標誌和 –rpcapi “admin,eth,net,web3,debug,shh” 執行 geth

from web3 import Web3, HTTPProvider
web3 = Web3(HTTPProvider('http://localhost:8545'))          

print ("web3 =", web3.version.api) #4.2.1
print(web3.shh) #error occurs

當我嘗試執行上面的以下程式碼時,出現以下錯誤:

Traceback (most recent call last):
 File "dd.py", line 11, in <module>
   print(web3.shh)
AttributeError: 'Web3' object has no attribute 'shh'

您需要執行以下操作:

from web3.shh import Shh
Shh.attach(web3, "shh")
print(web3.shh)

引用自:https://ethereum.stackexchange.com/questions/54370