Metamask stopped using web3. Their own API has no methods for interacting with ERC20, ERC721 contracts. How do I accomplish simple task of reading token balance for a wallet on an ERC721 contract?


  • Metamask stopped using web3. This is not true. Aug 2, 2022 at 12:30

1 Answer 1


Look at eth_call on Metamask API Docs.

Here is an example query for retrieving ERC20 balance:

"jsonrpc": "2.0",
"method": "eth_call",
"params": [
        "data": "0x70a0823100000000000000000000000028c6c06298d514db089934071355e5743bf21d60",
        "to": "0xdac17f958d2ee523a2206206994597c13d831ec7"
"id": 0

to is the contract address (in this case - USDT)

data consists of:

  1. the first 4 bytes of keccak256(balanceOf(address)) (function hash)
  2. the wallet address that you want to retrieve balance for (in this example - 0x28c6c06298d514db089934071355e5743bf21d60).

The same should work for NFTs since ERC721 balanceOf matches ERC20 specs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.