[英]web3 ABI doesn't work to get contract ownership on Ethereum mainnet
我正在使用 web3 API 處理 python。 我正在嘗試獲得部署在以太坊主網上的合同的所有權。 我可以發短信的最佳代碼如下:
from web3 import Web3
eth = "https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
web3 = Web3(Web3.HTTPProvider(eth))
abi = '''[
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"type": "function"
},
{
"inputs": [],
"payable": false,
"type": "constructor"
}
]'''
contract = web3.eth.contract(address=Web3.toChecksumAddress("0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"), abi=abi)
owner = contract.functions.owner().call()
print(owner)
但是,如果我嘗試執行代碼,則會出現以下錯誤:
web3.exceptions.ContractLogicError: execution reverted
也許 ABI 不適用於此 RPC,或者不知道發生了什么。 有人可以幫助我嗎? 謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.