0

I want to fork the polygon mainnet using hardhat but don't know why it's giving me this error:

Error HH604: Error running JSON-RPC server: Invalid JSON-RPC response's result.

Errors: Invalid value null supplied to : RpcBlockWithTransactions | null/transactions: RpcTransaction Array/0: RpcTransaction/accessList: Array<{ address: DATA, storageKeys: Array<DATA> | null }> | undefined, Invalid value null supplied to : RpcBlockWithTransactions | null/transactions: RpcTransaction Array/2: RpcTransaction/accessList: Array<{ address: DATA, storageKeys: Array<DATA> | null }> | undefined

or sometimes it gives me this error:

Error HH110: Invalid JSON-RPC response received: {
  "message":"No API key found in request"
}

I am also providing the API with rpc URL but still I am getting this error. I am able to make a curl request but don't know why this is happening. Is it a problem from my side or from the node provider?

This is the command I am running in the terminal for forking: yarn hardhat node --fork https://polygon-mainnet.g.alchemy.com/v2/<api-key>

1 Answer 1

0

The error is clearly displayed in your code - without your API key you’re not providing any method for connecting to the blockchain.

Go to, say, Alchemy here, create a free account and set up a new tool - fork_polygon_mainnet or whatever. Then choose that tool, click ‘view key’, and paste the API key provided there into your yarn command where it says <api-key>

If you still have issues, look at Alchemy’s docs. They have copy/paste utilities for forking networks, as well as a plethora of web3 & ethers.js type commands in their SDK - check out the composer on Alchemy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.