-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't connect to goerli via the default provider #3979
Comments
It should definitely be supported. I’ll look at this first thing in the morning. |
@GildedHonour Are you trying use |
@ricmoo Why My question is because @GildedHonour is using const provider = ethers.getDefaultProvider("goerli", {
etherscan: process.env.ETHERSCAN_API_KEY,
}); |
@jeftarmascarenhas-hotmart on a server |
I suppose it should have been |
const provider = ethers.getDefaultProvider("goerli", {
etherscan: process.env.ETHERSCAN_API_KEY,
}); |
Can you provide the error? |
Yes, that true. What do you think about change any to # needs add a provider like alchemy if you're working on server(ex: Node.js)
const provider = ethers.getDefaultProvider("goerli", {
etherscan: process.env.ETHERSCAN_API_KEY,
alchemy...
}); |
So, that can’t change in v6, as that isn’t backwards compatible. Ethers is used by a large number of projects, so maintaining backward compatibility is important. :) |
Ok, I understand. I create this discussion about Date below Thanks |
@ricmoo follow the error when user When code above is running TypeError: unsupported network (argument="network", value="goerli", code=INVALID_ARGUMENT, version=6.3.0)
at makeError (/Users/jeffmascarenhas/blockchain/project-contributies/ethersjs-test/node_modules/ethers/src.ts/utils/errors.ts:656:21)
at assert (/Users/jeffmascarenhas/blockchain/project-contributies/ethersjs-test/node_modules/ethers/src.ts/utils/errors.ts:680:25)
at assertArgument (/Users/jeffmascarenhas/blockchain/project-contributies/ethersjs-test/node_modules/ethers/src.ts/utils/errors.ts:692:5)
at new CloudflareProvider (/Users/jeffmascarenhas/blockchain/project-contributies/ethersjs-test/node_modules/ethers/src.ts/providers/provider-cloudflare.ts:21:23)
at Object.getDefaultProvider (/Users/jeffmascarenhas/blockchain/project-contributies/ethersjs-test/node_modules/ethers/src.ts/providers/default-provider.ts:52:28)
at main (/Users/jeffmascarenhas/blockchain/project-contributies/ethersjs-test/index.ts:16:27)
at Object.<anonymous> (/Users/jeffmascarenhas/blockchain/project-contributies/ethersjs-test/index.ts:32:1)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Module.m._compile (/Users/jeffmascarenhas/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1180:10) {
code: 'INVALID_ARGUMENT',
argument: 'network',
value: 'goerli'
}
0.168293502174358329 I think that validation is wrong. if (options.alchemy !== "-") {
try {
providers.push(new AlchemyProvider(network, options.alchemy));
} catch (error) { console.log(error); }
}
if (options.ankr !== "-" && options.ankr != null) {
try {
providers.push(new AnkrProvider(network, options.ankr));
} catch (error) { console.log(error); }
}
if (options.cloudflare !== "-") {
try {
providers.push(new CloudflareProvider(network));
} catch (error) { console.log(error); }
}
if (options.etherscan !== "-") {
try {
providers.push(new EtherscanProvider(network, options.etherscan));
} catch (error) { console.log(error); }
}
if (options.infura !== "-") {
try {
let projectId = options.infura;
let projectSecret: undefined | string = undefined;
if (typeof(projectId) === "object") {
projectSecret = projectId.projectSecret;
projectId = projectId.projectId;
}
providers.push(new InfuraProvider(network, projectId, projectSecret));
} catch (error) { console.log(error); }
}
/*
if (options.pocket !== "-") {
try {
let appId = options.pocket;
let secretKey: undefined | string = undefined;
let loadBalancer: undefined | boolean = undefined;
if (typeof(appId) === "object") {
loadBalancer = !!appId.loadBalancer;
secretKey = appId.secretKey;
appId = appId.appId;
}
providers.push(new PocketProvider(network, appId, secretKey, loadBalancer));
} catch (error) { console.log(error); }
}
*/
if (options.quicknode !== "-") {
try {
let token = options.quicknode;
providers.push(new QuickNodeProvider(network, token));
} catch (error) { console.log(error); }
} |
I've found the issue and am working on a solution. There are two problems happening that are confusing things. First, I The real problem seems that Alchemy has broken the ethers API key, which means that the initial sync needed by the fallback provider is failing. This is a problem; the FallbackProvider should be more resilient against a backend being down (that's its entire purpose), so I'm working on a fix for this, where a backend that reports a fatal error will get put in a penalty box for some period of time. As a quick work around, you can disable Alchemy: const provider = ethers.getDefaultProvider("goerli", { alchemy: "-" }); By setting any backend to a |
I've added a feature to the FallbackProvider which will exclude backends that result in a fatal error. It can be expanded in the future to let it re-attempt in the future, but for now a failed backend is permanently removed. A lot of additional stats are tracked for future use too, to enable more robust dispatching heuristics. Please ty it out and let me know if there are any further issues. :) |
Ethers Version
6.x
Search Terms
No response
Describe the Problem
Why doesn't this code work in 5.7.2
and no longer does in 6.x
?
How's it unsupported? According to the documentation of the v6, it should work.
How to connect to "goerli" via the default provider?
And the same error will get thrown for "sepolia" as well.
Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
No response
Environment (Other)
No response
The text was updated successfully, but these errors were encountered: