Closed 0xlucyy closed 1 year ago
@0xlucyfer ConciseContract
is deprecated and was completely removed in v6
. I'm not sure if that's why you're getting your errors but I get the same values as etherscan with the following:
CONTRACT_ADDRESS = "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85"
abi = _get_contract_abi(CONTRACT_ADDRESS) # get abi using etherscan's API
contract_instance = w3.eth.contract(
abi=abi,
address=CONTRACT_ADDRESS,
)
_hash = 79798792360514604897274867475268942709375420329084632479380508457991614511774
expires = contract_instance.functions.nameExpires(_hash).call()
owner = contract_instance.functions.ownerOf(_hash).call()
I'm going to close this since I can't reproduce it but feel free to reply here if it still is not working right and you think we have a bug. I can re-open. Best of luck!
@0xlucyfer for the record, I did try with the deprecated ConciseContract
class and I still get the correct results (as I would expect). I feel like something else is going on in your setup if you are not getting the correct results. Is your Web3
instance connected to mainnet? Often times the same contract address is shared across chains and if you are connected to another chain you will get different results.
I am running a geth dappnode, seems that geth is unable to update, so it is 2 versions behind. That is likely the cause of this issue. When I use my infuria provider, I get the same outputs locally as etherescan returns.
When is v6 coming out? Might be a good idea to add a deprecated
tag to the function.
It is a lot more sloppy to have to call this contract_instance.functions.METHOD().call()
instead of contract_instance.METHOD()
Might be a good idea to add a deprecated tag to the function.
Do you mean in the docs? It has had a deprecation message for about 4 years. Would be good to know if that isn't coming through correctly.
It is a lot more sloppy to have to call this contract_instance.functions.METHOD().call() instead of contract_instance.METHOD()
It sure isn't as nice. The preferred way to more concisely call a contract function is to use the ContractCaller
API:
expires = contract_instance.caller.nameExpires(_hash)
edit: The docs seem to be updated as well here
Why is the ContractCaller
api preferred over ContractFunction
api?
I prefer to have the transaction object in the back of the contract instance declaration. ContractCaller
, I believe the transaction object goes in the middle of the code, syntactically.
ContractCaller
myContract.\
caller(BASIC_TRANSACTION(w3, account.address)).\
contract_func(x, y)
ContractFunction
myContract.functions.\
contract_func(x, y).\
buildTransaction(BASIC_TRANSACTION(w3, account.address))
Turns out I was getting bad data from my local geth node because I had not launched a beacon client. I launched lighthouse, and then my geth client started returning accurate data once more.
pip freeze
outputWhat was wrong?
My local ENS: Base Registrar instance is returning different data than etherscan. Notice variables
expires
&owner
.Local contract instance returns
1655715014
while read_contract on etherscan returns1696587563
.Local contract instance reverts while read_contract on etherscan returns
0xFC2DdF666D313614041e52E2cc18aEEDB1ba9348
Looking inside contract_instance
Node
How can it be fixed?
Any ideas?
Note: We prefer to use issues to track our work. If you think you've encountered a bug in web3py or have a feature request, you're in the right place. If you have implementation or usage questions, please refer to our documentation and/or join the conversation on discord.