-2

I need a universal code on python. I tried to get the right code myself but always the result was that I get eth balance and not all tokens. Please help me. I need the code to take 0x wallet as input, and just the sum of all tokens + nft as output

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

You need to provide addresses for all the ERC20 tokens and NFT's to get their balance. Otherwise using the balance function provided by web3 you can only the ETH balance of your wallet. Like this :

token_contract = web3.eth.contract(token_address, token_abi);

balance = token_contract.methods.balanceOf(wallet_address).call()