I wanna get a token balance with eth_call

Hi. I tried to get USDC token balance with eth_call.

As a test, I checked this ranking( Subscan | Aggregate Substrate ecological network high-precision Web3 explorer ) and ran the below command.

URL: https://evm.astar.network

Post body:
{
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [
        {
            "to": "0x6a2d262D56735DbA19Dd70682B39F6bE9a931D98",
            "data": "0x70a08231000000000000000000000000BB1290c1829007F440C771b37718FAbf309cd527"
        },
        "latest"
    ],
    "id": 0
}

Yes, good response.

{
    "jsonrpc": "2.0",
    "result": "0x00000000000000000000000000000000000000000000000000000069d3619081",
    "id": 0
}

The value of the balance matches the data in the explorer.

If the body of the post is as following,

{
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [
        {
            "to": "0x6a2d262D56735DbA19Dd70682B39F6bE9a931D98",
            "data": "0x70a08231000000000000000000000000889CEF5559EB8b6a1dBCC445fB479e5530c37D8f"
        },
        "latest"
    ],
    "id": 0
}

I got this response which token balance was zero.

{
    "jsonrpc": "2.0",
    "result": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "id": 0
}

However there are several USDC for this account.

Why is the balance in response zero?

GM

The API is correct here, it’s just Subscan interface that is wrong.

These tokens (USDC @ 0x6a2d262d56735dba19dd70682b39f6be9a931d98) have been moved by the owner 0x889CEF5559EB8b6a1dBCC445fB479e5530c37D8f here

The contract was approved by this address here

2 Likes

Thank you! I got it.

By the way how did you get to the bottom of it?

And can I assume that both subscan and blockscout are a block explorer like Etherscan?
I was thinking that subscan was better than blockscout because I found the following message in blockscout.
“29% Blocks With Internal Transactions Indexed - We’re indexing this chain right now. Some of the counts may be inaccurate.”

However, subscan in the above example is incorrect.

Which do you think is better?

The bottom of it? Sorry not sure what you mean.

Subscan is the reference for native transactions explorer, while blockscout is the reference for EVM explorer, this is historical at least, Subscan support of EVM is more recent hence the bugs.

The banner on Blockscout is just referring to indexing of trace logs, there are current works on this but all infos displayed are accurate, it’s just older transactions that miss extra (debug) details.

1 Like

I wanted to say how did you find out that SUBSCAN was wrong.

Okay. Thank you.
I understood the following.
Subscan: supporting the WASM and EVM transaction about Astar.
Blockscout: supporting only EVM transaction about Astar.

Well it’s very rare that RPC would be faulty, so seemed more obvious that an error would come from explorers which rely on RPC for data ingestion.

1 Like