question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InfuraProvider throws an Error

See original GitHub issue

I’m attempting to use the InfuraProvider to connect to the ropsten network but I get an error when doing so.

Doing this

const provider = new InfuraProvider(
  "ropsten",
  "780797e7832148289ef283af4ade0a58"
);
provider.getBlockNumber().then(console.log);

results in the following error:

index.js:165 Uncaught (in promise) Error: missing response (serverError={}, url="https://ropsten.infura.io/v3/780797e7832148289ef283af4ade0a58", code=SERVER_ERROR, version=web/5.0.0-beta.141)
    at Logger.makeError (index.js:165)
    at Logger.throwError (index.js:174)
    at index.js:100
    at Generator.throw (<anonymous>)
    at rejected (index.js:6)

As a sanity check using I made sure I could access the Infura endpoint with my project id using curl which works

curl -X POST \   
-H "Content-Type: application/json" \
--data '{"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": []}' \
"https://ropsten.infura.io/v3/780797e7832148289ef283af4ade0a58"

Note: Infura project ID is a throw-away that will be deleted once this is resolved 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
extramilegitcommented, Jun 8, 2021

My lines of code const network = “mainnet”; const provider = new ethers.providers.InfuraProvider(network, { projectId: “c3db272c665f70df0d9”, projectSecret: “1b326380e58328ea6” });

const getBalanceAsync = async (address) => { let rawBalance = await provider.getBalance(address); return (rawBalance); }

1reaction
extramilegitcommented, Jun 8, 2021

This is the response i get when i want to fetch balance using Infura. Please what is wrong

[Unhandled promise rejection: Error: bad response (status=400, headers={“vary”:“Origin”,“content-type”:“application/json”,“date”:“Tue, 08 Jun 2021 15:01:22 GMT”,“content-length”:“74”}, body=“{"jsonrpc":"2.0","error":{"code":-32600,"message":"invalid json request"}}”, requestBody=“{"method":"eth_getBalance","params":["0x77ab999d1e9f152156b4411e1f3e2a42dab8cd6d","latest"],"id":42,"jsonrpc":"2.0"}”, requestMethod=“POST”, url=“https://mainnet.infura.io/v3/c3db1af154164**************9”, code=SERVER_ERROR, version=web/5.3.0)]

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle wrong chain error [Infura, Wagmi, React ...
InfuraProvider (chainId, infuraId); const chains: Chain[] ... Everything is working correctly, that error just gets thrown when I run the app ...
Read more >
Using Infura (or a custom provider) - Truffle Suite
This tutorial will show you how to use Infura to migrate an existing dapp to an Ethereum network supported by Infura. In this...
Read more >
could not detect network (event="noNetwork", code - You.com
I am currently following the step by step video guide and stumbled on this issue regarding the json-rpc-provider. Has anyone been able to...
Read more >
Configuring Chains - wagmi
If a provider does not support a chain, it will fall back onto the next one in the array. If no RPC URLs...
Read more >
node.js - Is there an issue with the Infura provider project ID or ...
js part, the code executes through console logging the mnemonic and address, and then throws the below error. UnhandledPromiseRejectionWarning: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found