getDefaultProvider() throws error
I am trying to use getDefaultProvider as laid out in the docs here https://usedapp-docs.netlify.app/docs/Getting%20Started/Reading My Config
import "./index.css";
import { DAppProvider, Mainnet, Goerli, Rinkeby } from "@usedapp/core";
import React from "react";
import ReactDOM from "react-dom";
import { getDefaultProvider } from "ethers";
import App from "./App";
export const SUPPORTED_CHAIN = Goerli.chainId;
const ALCHEMY_PROJECT_ID = "habYaoNBLfpJJOlwRMYOOauC_2vd4Dgv";
const config = {
readOnlyChainId: Goerli.chainId,
readOnlyUrls: {
[Goerli.chainId]: getDefaultProvider('goerli', {alchemy: ALCHEMY_PROJECT_ID}),
},
multicallVersion: 2,
networks: [Goerli],
}
ReactDOM.render(
<React.StrictMode>
<DAppProvider config={config}>
<App />
</DAppProvider>
</React.StrictMode>,
document.getElementById("root"),
);
But it keeps throwing an exception;
index.js:1 Error: missing URL (argument="connection.url", value={"_isProvider":true,"_events":[],"_emitted":{"block":-2},"disableCcipRead":false,"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"goerli","chainId":5,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_maxFilterBlockRange":10,"_pollingInterval":4000,"_fastQueryDate":0,"providerConfigs":[{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"disableCcipRead":false,"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"goerli","chainId":5,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_maxFilterBlockRange":10,"_pollingInterval":4000,"_fastQueryDate":0,"connection":{"allowGzip":true,"url":"https://goerli.infura.io/v3/84842078b09946638c03157f83405213"},"_nextId":42,"apiKey":"84842078b09946638c03157f83405213","projectId":"84842078b09946638c03157f83405213","projectSecret":null},"weight":1,"stallTimeout":2000,"priority":1},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"disableCcipRead":false,"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"goerli","chainId":5,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_maxFilterBlockRange":10,"_pollingInterval":4000,"_fastQueryDate":0,"baseUrl":"https://api-goerli.etherscan.io","apiKey":"9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB"},"weight":1,"stallTimeout":2000,"priority":1},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"disableCcipRead":false,"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"goerli","chainId":5,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_maxFilterBlockRange":10,"_pollingInterval":4000,"_fastQueryDate":0,"connection":{"allowGzip":true,"url":"https://eth-goerli.alchemyapi.io/v2/hxeYaoNBLfpJJOlwRMYOOauC_2vd4Dgv"},"_nextId":42,"apiKey":"habYaoNBLfpJJOlwRMYOOauC_2vd4Dgv"},"weight":1,"stallTimeout":750,"priority":1}],"quorum":1,"_highestBlockNumber":-1,"headers":{"content-type":"application/json"}}, code=INVALID_ARGUMENT, version=web/5.6.0) at Logger.makeError (index.ts:261:1) at Logger.throwError (index.ts:273:1) at Logger.throwArgumentError (index.ts:277:1) at _fetchData (index.ts:122:1) at fetchJson (index.ts:398:1) at JsonRpcProvider.send (json-rpc-provider.ts:443:1) at JsonRpcSigner.getAddress (json-rpc-provider.ts:159:1) at tryToGetAccount (provider.tsx:14:1) at provider.tsx:55:1 at activate (useEthers.ts:53:1) at NetworkActivator.tsx:29:1 at invokePassiveEffectCreate (react-dom.development.js:23487:1) at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1) at invokeGuardedCallback (react-dom.development.js:4056:1) at flushPassiveEffectsImpl (react-dom.development.js:23574:1) at unstable_runWithPriority (scheduler.development.js:468:1) at runWithPriority$1 (react-dom.development.js:11276:1) at flushPassiveEffects (react-dom.development.js:23447:1) at react-dom.development.js:23324:1 at workLoop (scheduler.development.js:417:1) at flushWork (scheduler.development.js:390:1) at MessagePort.performWorkUntilDeadline (scheduler.development.js:157:1)
I tried to recreate that bug and everything is okay in my dapp. Do you have still that problem?
Yes. I have tried using just getDefaultProvider(“goerli”). Same error.
Sent from ProtonMail for iOS
On Wed, Apr 20, 2022 at 2:39 PM, Francisldn @.***> wrote:
Have you tried to run without the Infura provider? You don't need a provider for reading from blockchain, also the example in https://usedapp-docs.netlify.app/docs/Getting%20Started/Reading doesn't supply a provider.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
@dydxcrypt Which version of @usedapp/core and of ethers do you have installed?