Failed to block info and logs

Request to get block info using ethers.js(6.13.1) failed with the following error response:

{"message":"response body is not valid JSON (operation=\"bodyJson\", info={ \"response\": {  } }, code=UNSUPPORTED_OPERATION, version=6.13.1)","stack":"Error: response body is not valid JSON (operation=\"bodyJson\", info={ \"response\": {  } }, code=UNSUPPORTED_OPERATION, version=6.13.1)\n    at makeError (/***modules/ethers/src.ts/utils/errors.ts:694:21)\n    at assert (/***modules/ethers/src.ts/utils/errors.ts:715:25)\n    at FetchResponse.get bodyJson [as bodyJson] (/***modules/ethers/src.ts/utils/fetch.ts:832:19)\n    at JsonRpcProvider._send (/***modules/ethers/src.ts/providers/provider-jsonrpc.ts:1247:29)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async /***modules/ethers/src.ts/providers/provider-jsonrpc.ts:537:40"}

Request to get block logs using ethers.js(6.13.1) failed with the following error response:

{"message":"could not coalesce error (error={ \"code\": -32602, \"data\": \"unknown field `params.0.blockHash`, expected one of `fromBlock`, `toBlock`, `address`, `topics`, `blockHash` at line 1 column 182\", \"message\": \"Invalid params\" }, payload={ \"id\": 13320, \"jsonrpc\": \"2.0\", \"method\": \"eth_getLogs\", \"params\": [ { \"blockHash\": \"0x3768463d9e69955a5e7d168f1847fb6c00108c98ea447412594cbd8fe0fac9a9\", \"topics\": [ \"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\" ] } ] }, code=UNKNOWN_ERROR, version=6.13.1)","stack":"Error: could not coalesce error (error={ \"code\": -32602, \"data\": \"unknown field `params.0.blockHash`, expected one of `fromBlock`, `toBlock`, `address`, `topics`, `blockHash` at line 1 column 182\", \"message\": \"Invalid params\" }, payload={ \"id\": 13320, \"jsonrpc\": \"2.0\", \"method\": \"eth_getLogs\", \"params\": [ { \"blockHash\": \"0x3768463d9e69955a5e7d168f1847fb6c00108c98ea447412594cbd8fe0fac9a9\", \"topics\": [ \"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\" ] } ] }, code=UNKNOWN_ERROR, version=6.13.1)\n    at makeError (/***modules/ethers/src.ts/utils/errors.ts:694:21)\n    at JsonRpcProvider.getRpcError (/***modules/ethers/src.ts/providers/provider-jsonrpc.ts:1059:25)\n    at /***modules/ethers/src.ts/providers/provider-jsonrpc.ts:563:45\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)"}

Code snippet:

const fetchRequest = new FetchRequest('MORALIS_RPC');
const jsonRpcProvider = new ethers.JsonRpcProvider(fetchRequest, this.chainId, { staticNetwork: Network.from(this.chainId) });

const blockNumber = 123456; // replace with some block number
const blockHash = 'abcdef'; // replace with some block hash

// Get block data
const block = await jsonRpcProvider.getBlock(blockNumber, true);

// Get block logs
const filter: FilterByBlockHash = {
        blockHash: blockHash,
        topics: [ethers.id('Transfer(address,address,uint256)')],
      };
const logs = await jsonRpcProvider.getLogs(filter)
1 Like

I have the same problems.

So the case with get block logs(eth_getLogs) really strange. It was reproduced in ETH mainnet.

Hi @VladLypovy

Thanks for the report. Our developers have taken note of the issue and will work on fixing itπŸ™.

2 Likes

Thanks you, please let us know on updates

2 Likes