RPC Nodes - ETH and Get ERC-20 balance

Modified on Tue, 14 Feb 2023 at 04:50 PM

It is possible to get the balance of an ERC-20 token via an RPC-Node call.


See example:

curl --location --request POST 'https://api.tatum.io/v3/blockchain/node/ETH/' \
--header 'x-api-key: ##Mainnet_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw ' {
    "id":42,
    "jsonrpc":"2.0",
    "method":"eth_call",
    "params":[
        {
            //0x70a08231 is the "Keccak hash" for "balanceOf" &&  24 zeroes && ETH address holding the token (without 0x)
            "data":"0x70a0823100000000000000000000000069823872E61f8b8bB57E79CC28E09DC27B11a4Ab",
            "to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" // tokenAddress (ERC-20 ContractAddress)
        },
    "latest"
    ]
  }'

//Response: 

{
    "jsonrpc": "2.0",
    "id": 42,
    "result": "0x00000000000000000000000000000000000000000000000003fabd9b1157e000" // convert hex to decimal
}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article