I'm having trouble with getting EthereumProvider to connect via the Infura API key. I use it in my connection logic like this:

const provider = await EthereumProvider.init({
                    projectId: process.env.NEXT_PUBLIC_INFURA_ID!,
                    showQrModal: true,
                    optionalChains: [1, 5, 11155111],
                await provider.enable()

After clicking the connect button that calls this method, I get this error:

Error: WebSocket connection closed abnormally with code: 3000 (Authorization error: Project not found)

The env variable is being retrieved fine, as I checked it in console.log, and also tried hardcoding the projectId, still won't work. I'm working on localhost, and I checked the Infura API key to have active endpoints for Mainnet, Goerli, and Sepolia (the chains I specify).

I've checked all the issues people had with this EthereumProvider, but no one had an issue like this one. I would very much appreciate any help, thanks!

  • What do you see if you do curl https://mainnet.infura.io/v3/{YOUR_INFURA_ID} -X POST -H “Content-Type: application/json” -d ‘{“jsonrpc”:“2.0”,“method”:“eth_blockNumber”,“params”: [],“id”:1}’ in th terminal?
    – Mila A
    Commented Jan 30 at 15:20
  • 1
    @MilaA I get {"jsonrpc":"2.0","error":{"code":-32002,"message":"rejected due to project ID settings"}} if I run this from the terminal Commented Jan 31 at 9:05
  • 1
    I've tried that before, it won't help. I still get the same message from the terminal and the website. I've added it as http://localhost:3000/, http://localhost/, localhost, localhost:3000, *my ip*, *my ip*:3000 and http://*my ip*:3000/ to the allowlist's origins Commented Feb 1 at 7:55
  • 1
    I've checked all the threads mentioned and still don't know how can I use it in my case. I can't switch to an HTTP endpoint because Wallet Connect EthereumProvider does not provide that as an option, as far as I've seen on the documentation, which is a bit outdated anyway. About the other ones, I'm sending a request straight from the terminal (as you suggested for troubleshooting), what does whitelist the contract address mean in this context? Also, the other options I have configured as suggested. Sorry if the questions may be dumb, as I'm new to the space and just doing my second project Commented Feb 2 at 9:52
  • 1
    I'll check them out, and if I won't be able to find a solution — will post this issue on the Infura forum. Thanks! Commented Feb 2 at 13:12


Your Answer

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