ethereum - 调用 web3.eth.get_transaction() 但它显示“没有属性'get_transaction'”
问题描述
我是 web3 的新手。最近我正在尝试根据这篇文章解码以太坊上的一些日志。但是当我尝试使用类似receipt=web3.eth.get_transaction(transaction_hash)
. 它一直在向我展示module 'web3.eth' has no attribute 'get_transaction'
。但显然,我的电脑有这个文件。而且,这种说法不是意味着“我正在尝试调用 web3.eth 中的函数”吗?为什么将其视为“调用属性”?
这是我的代码:
import json
import requests
from web3 import Web3
w3=Web3(Web3.HTTPProvider(infura_project))
receipt=web3.eth.get_transcation(transaction Hash) //always show error "web3.eth has no attribute get_transaction"
log=receipt["logs"][2]
smart_contract=log["address"]
mykey="MY API Key of Etherscan"
adi_endpoint=f"https://api.etherscan.io/api?module=contract&action=getabi&address={smart_contract} & apikey={mykey}" //problem (2)
abi=json.load(requests.get(adi_endpoint).text)
//decode info
如果我直接将我的 Etherscan API 密钥放在第 10 行的末尾,pycharm 会在其中标记一个错误。因此,我将 API 密钥用双引号括起来,并将其分配给变量“mykey”。老实说,我认为这行不通。如何解决这个问题呢?
解决方案
推荐阅读
- r - RMarkdown 可折叠面板
- jquery - Select2 向列表中添加一个新值
- javascript - 使用 node.js 进行 mysql 查询的未定义结果
- php - 如何在我自己的网站上显示网站的主页?
- javascript - 无法设置更新对象属性的状态
- javascript - 如何实现搜索框以查找任何文本中的任何文本使用角 5
- android - Linearlayout manager + recyclerview:StackFromEnd(true) 仍然显示在顶部而不是底部
- python - Wit.ai Facebook Messenger 聊天机器人最近没有使用 Python 接收或接收消息
- laravel - 表格中的表单提交按钮没有功能
- ajax - MissingServletRequestParameterException:必需的长参数 prod_id 不存在