Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Invalid JSON RPC response while using RPC raw call #5826

@lucasfras

Description

@lucasfras

This is not a Bug Report, Feature Request, or related to Documentation

  • I have searched the existing issues

Is there an existing issue for this?

  • I have searched the existing issues

What's up?

I'm trying to make an RAW RPC call, it's working on my Network page I can see the request and the response, but the callback function of the web3.currentProvider.send method is returning error. I don't know why that's happening.

My code

    const getTransactionFromTo = async () => {
            let totalBlocks = await web3.eth.getBlockNumber();
            let transactions = [];
            for(let i = 0; i < 1; i++){
                web3.currentProvider.send({
                    jsonrpc: "2.0",
                    id: 1,
                    method: "eth_getBlockRange",
                    params: ["0x" + (totalBlocks-10).toString(16), "0x" + totalBlocks.toString(16), true]
                }, (err, res) => {
                    if (err) {
                        console.log(err)
                        console.log('res', res)
                        return;
                    }
    
                    const arrResult = res.result;
    
                    for(let i = 0; i < arrResult.length; i++){
                        let info = {};
                        let hour = new Date(arrResult[i].timestamp * 1000).getHours().toString();
                        info.hour = hour;
                        info.count = arrResult[i].transactions.length;
                        transactions.push(info);
                    }
                    resolve(transactions);
                });
                totalBlocks -= 1000;
            }
    };

Error
image

Request in network tab
image
image

Examples/References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions