This doesn't work and throw: Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.0.23)
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/XXX');
console.log(await provider.getBlockNumber());
What's happening ? I don't wanna use the InfuraProvider.
I got the same could not detect network error when I used a bad infura project id. It worked fine if the project id is valid. May be double check your infura project id? Also, does it work if you use InfuraProvider?
Yes it works with InfuraProvider like so const provider = new ethers.providers.InfuraProvider('homestead', XXX); ...
Can you check your url? My infura url (so is ethers default url) looks like this:
https://mainnet.infura.io/v3/{project_id}
Wow thank you so much, I forgot /v3/ completely missed it... next time I'll copy paste lol, thank you !
Most helpful comment
Can you check your url? My infura url (so is ethers default url) looks like this:
https://mainnet.infura.io/v3/{project_id}