Very long synchronization with the network. What could be the reason and how to accelerate? Thanks!
Hi @Dan_Dan welcome to our community. Can you describe in more detail what you are trying to do and the issues you are seeing. We would love to help you out!
I am getting this error message when trying to call balanceOf function inside contract:
‘Could not transact with/call contract function, is contract deployed correctly and chain synced?’
Can someone point me in the right direction?
Thanks.
I am trying to get ERC20 contract balance in my MetaMask wallet using python. What am I doing wrong? Thanks.
import json
from web3 import Web3
MyWalletAddress = ‘…’
USDC_Address = ‘0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48’
API_KEY = ‘…’
ETHERSCAN_KEY = ‘…’
infura_url = 'https://mainnet.infura.io/v3/’+API_KEY
link = 'http://api.etherscan.io/api?module=contract&action=getabi&address=’+USDC_Address+’&apikey=’+ETHERSCAN_KEY
print (link)
f = requests.get(link)
print(f.text)
json = json.loads(f.text)
abi = json[‘result’]
w3 = Web3(Web3.HTTPProvider(infura_url))
contr = w3.eth.contract(MyWallet_address, abi=abi)
wei = contr.functions.balanceOf(MyWalletAddress).call()
balance = w3.fromWei(wei,‘ether’)
print (balance)
Mike, did you get a chance to check my code?
Hi @gkish, I believe this tutorial outlines how to do this https://blog.infura.io/dapp-frontend-network/ can you give that a try and let us know if that helps?