我在python代码中使用Web3.py。代码是这样的
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://ropsten.infura.io/"))*
for i in range(5000000,5100000):
print(i)
transactionArray = []
blockResult = w3.eth.getBlock(i)
for tx in blockResult["transactions"]:
txResult = binascii.hexlify(tx).decode()
print(txResult)
transactionResult = w3.getTransactionReceipt(txResult)
print(transactionResult)
执行此代码时,出现错误
5000000
Traceback (most recent call last):
File "Test06.py", line 27, in <module>
for tx in blockResult["transactions"]:
TypeError: 'NoneType' object is not subscriptable
但是如果我从4571699开始,它会给我结果。有人可以告诉我为什么我从范围5000000开始出现错误
我使用MAIN NET,因此解决了此问题。但是现在我得到一个错误
Traceback (most recent call last):
File "Test06.py", line 35, in <module>
transactionResult = w3.getTransactionReceipt(txResult)
AttributeError: 'Web3' object has no attribute 'getTransactionReceipt'.
答案 0 :(得分:1)
您正在使用的是ropsten测试链,截至该答案为止,该链只有4572019个块。