Skip to content
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

Issue with localhost provider #91

Open
naushad2403 opened this issue May 14, 2023 · 0 comments
Open

Issue with localhost provider #91

naushad2403 opened this issue May 14, 2023 · 0 comments

Comments

@naushad2403
Copy link

Describe the bug
Using hardhat local node and metamask, Configuring Wagmi client with jsonRpcProvider,
Error I am getting is networkConfigurationId undefined does not match a configured networkConfiguration
To Reproduce
Steps to reproduce the behavior:

  1. Replace the content of _app.js of frontend folder with the following code.
  2. Run npx hardhat node in backend folder
  3. Run npx run dev in frontend folder
  4. Select localhost network in metamask
  5. Try to connect with connect
import "../styles/globals.css";
import "@rainbow-me/rainbowkit/styles.css";

import { getDefaultWallets, RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { configureChains, createClient, useAccount, WagmiConfig } from "wagmi";
import {
  localhost,
} from "wagmi/chains";
import { alchemyProvider } from "wagmi/providers/alchemy";
import { publicProvider } from "wagmi/providers/public";
import MainLayout from "../layout/mainLayout";
import { useRouter } from "next/router";
import { jsonRpcProvider } from "@wagmi/core/providers/jsonRpc";

const { chains, provider } = configureChains(
  [
    localhost
  ],
  [
    jsonRpcProvider({
      rpc: (chain) => ({
        http: `http://127.0.0.1:8545/`,
      }),
    }),
  ]
);

console.log(chains, provider);

const { connectors } = getDefaultWallets({
  appName: "My Alchemy DApp",
  chains,
});

const wagmiClient = createClient({
  autoConnect: true,
  connectors,
  provider,
});

export { WagmiConfig, RainbowKitProvider };

function MyApp({ Component, pageProps }) {
  const router = useRouter();
  const account = useAccount({
    onConnect({ address, connector, isReconnected }) {
      console.log(address);
      if (!isReconnected) router.reload();
    },
  });
  return (
    <WagmiConfig client={wagmiClient}>
      <RainbowKitProvider
        modalSize="compact"
        initialChain={process.env.NEXT_PUBLIC_DEFAULT_CHAIN}
        chains={chains}
      >
        <MainLayout>
          <Component {...pageProps} />
        </MainLayout>
      </RainbowKitProvider>
    </WagmiConfig>
  );
}


Expected behavior
App should connect with wallet and show address.

Screenshots
Screenshot 2023-05-14 at 2 14 44 PM

Desktop (please complete the following information):

  • OS: MacOS ventura 13.4
  • Browser Charome

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant