WMATIC_contract = w3.eth.contract(address = WMATIC_address, abi = WMATIC_contract_abi)
WMATIC_balance = WMATIC_contract.functions.balanceOf(myContractAddress).call()
I use the above web3.py snippet to query wmatic balance of myContractAddress in Hardhat, but it always returns 0. The snippet works fine with querying real address, and does not work for virtual contract address, i.e., my deployed contract address in Hardhat, and there is wmatic indeed in myContractAddress. anybody can help?

Dec 18, 2023, 1:36 PM
WMATIC_contract = w3.eth.contract(address = WMATIC_address, abi = erc20_abi)
I also tried erc20_abi, still failed.
Dec 18, 2023, 1:37 PM

© 2024 Draquery.com All rights reserved.