Developers Forum for XinFin XDC Network

xu zhaolin
xu zhaolin

Posted on

xdc dosent suport eth_call with specific blockhash

We are doing graph-node compatibility project.

We post

curl -X POST https://arpc.apothem.network/ -H "Content-Type: application/json" -d '
{
    "id": 348,
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [
        {
            "data": "0x06fdde03",
            "gas": "0x2faf080",
            "to": "0x53350795c11cee781a7e174479778f848d76ab2a"
        },
        {
            "blockHash": "0xe8ec0bfc021f839fd0a69ae89689e309632af2cc434e8a096732068f0736864b"
        }
    ]
}'

The response became

{"jsonrpc":"2.0","id":348,"error":{"code":-32602,"message":"invalidargument 1: hex string without 0x prefix"}}

It seems like xdc doesn’t support eth_call ?

One more thing worth mentioning here.

curl -X POST https://arpc.apothem.network/ -H "Content-Type: application/json" -d '
{
    "id": 348,
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [
        {
            "data": "0x06fdde03",
            "gas": "0x2faf080",
            "to": "0x53350795c11cee781a7e174479778f848d76ab2a"
        },
        "latest"
    ]
}'

If we change the second parameter to “latest “ it will return the correct value

{"jsonrpc":"2.0","id":348,"result":"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f44656d6f20476f6c6420546f6b656e0000000000000000000000000000000000"}

which means xdc only supports eth_call when parameter is “latest”
but not specific blockhash.

This is a serious problem for graph-node compatibility because graph’s subgraph will extract readonly function via eth_call.

Discussion (2)

Collapse
wjrjerome profile image
Blockchain Minions • Edited on

have you tried using block number hex instead of passing the block hash directly?
Looking into the web3 implementation, it is expecting the second parameters to be block number rather than hash.(except those enum such as "latest").

I have tested with the block number 0x22b2277 which is block num for this hash 0xe8ec...64b you provided. Below is what it returned:

curl -X POST https://arpc.apothem.network/ -H "Content-Type: application/json" -d '
{
    "id": 348,
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [
        {
            "data": "0x06fdde03",
            "gas": "0x2faf080",
            "to": "0x53350795c11cee781a7e174479778f848d76ab2a"
        },
        "0x22b2277"
    ]
}'

{"jsonrpc":"2.0","id":348,"result":"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f44656d6f20476f6c6420546f6b656e0000000000000000000000000000000000"}
Enter fullscreen mode Exit fullscreen mode

Looking at some of the eth API documentation, it also suggest eth_call shall be using block num in hex format OR use the enum it provided, see

Collapse
wjrjerome profile image
Blockchain Minions

Interesting. Will take a look.