Error calling eth_estimateGas with Relay's JSON RPC Endpoint

I'm following along the docs in order to call eth_estimateGas with Relay's JSON RPC endpoint:

https://eth.wiki/json-rpc/API#parameters-25

Here's my code:

const params = JSON.stringify({
  to: '0xD79FFD274Bc1c0c9695fda8f774bf6E7B9225EAF',
  data: '0x4641257d',
})
const result = await relayer.call('eth_estimateGas', [params, 'latest'])

But, I'm getting this error:

{
  jsonrpc: '2.0',
  id: 1,
  error: {
    code: -32602,
    message: 'invalid argument 0: json: cannot unmarshal string into Go value of type ethapi.CallArgs'
  }
}

Anyone know what the error means?

Hi @jg22,

Can you try without stringifying your params

const params = {
  to: '0xD79FFD274Bc1c0c9695fda8f774bf6E7B9225EAF',
  data: '0x4641257d',
}
const result = await relayer.call('eth_estimateGas', [params, 'latest'])

I'm not able to. The function signature for call is call(method: string, params: string[]): Promise<JsonRpcResponse>;. I'm on node ts btw.

Regardless, I did try to force the object as a param like you suggested by transpiling without type checking, but that didn't work either (forgot what the error was).

(post deleted by author)

@dylkil any updates on this issue? I'm running into the same problem when trying to call eth_estimateGas via a relayer

I've just made a successful eth_estimateGas call with the following body:

{
  "jsonrpc": "2.0",
  "method": "eth_estimateGas",
  "params": [{
    "to": "0xbce6e614f6452cee006fd7d6366681bc0b382049",
    "speed": "fast",
    "data": "0x7eb28b9300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000f2438a14f668b1bba53408346288f3d7c71c10a10000000000000000000000001636cc38a69a79bcdac846e4690304e0124f70ea0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000009896800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000a6163636f756e742d69640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000064"
  }, "latest"],
  "id": 1
}