Connect to a local blockchain using web3auth SDK

Hello,

I’m trying to connect to a local blockchain created using Ganache with the web3auth/single-factor-auth javascript SDK.

I’m using the Next.js quick start demo from the offical repository and replaced the chain Id and RPC url from the one’s I get from Ganache.

When trying to connect I have this error inside my browser console :

Uncaught (in promise) WalletInitializationError: Wallet is not ready yet, Please call init first.

It works with real blockchain tho, it’s just with local one’s where I can’t enable the connection.

This is my chain configuration:

// IMP START - Chain Config
const chainConfig = {
  chainNamespace: CHAIN_NAMESPACES.EIP155,
  chainId: "114",
  rpcTarget: "http://127.0.0.1:3001",
  // Avoid using public rpcTarget in production.
  // Use services like Infura, Quicknode etc
  displayName: "Flare Testnet Coston2",
  blockExplorerUrl: "https://coston2-explorer.flare.network",
  ticker: "C2FLR",
  tickerName: "Coston2 Flare",
  logo: "https://cryptologos.cc/logos/ethereum-eth-logo.png",
};
// IMP END - Chain Config

// IMP START - SDK Initialization
const privateKeyProvider = new EthereumPrivateKeyProvider({
  config: { chainConfig },
});

const web3auth = new Web3Auth({
  clientId, // Get your Client ID from Web3Auth Dashboard
  web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
  privateKeyProvider,
});

Have you some ideas about what I’m doing wrong ?

Thank you,

Hello Wade,

Thanks for reaching out! It looks like you’re trying to use the Web3Auth SDK to connect to a local blockchain set up with Ganache. You’re encountering a WalletInitializationError indicating the wallet isn’t ready. Here’s what might help:

  1. Initialization Order: Ensure the web3auth.init() method is called before attempting any login or blockchain interactions. This prepares the SDK and should typically resolve the wallet readiness issue.

  2. Chain Config: Double-check if Ganache is running and accessible at the specified RPC URL (“http://127.0.0.1:3001”) and chain ID (“114”) in your configuration. Sometimes, Ganache might use different ports.

  3. Web3Auth Network: Since you’re working locally, ensure that the web3AuthNetwork setting is appropriate. Depending on your specific SDK version and setup, you might need to adjust this. Local setups may not usually work with real blockchain networks like SAPPHIRE_MAINNET.

Let me know if making these adjustments helps resolve the issue, or if you need further support!

Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

Hey @kerstensreda

Thank you for your suggestion regarding support for local blockchains within the Web3Auth SDK. Currently, connecting to local blockchain environments like Ganache is not officially supported. However, we recognize the importance of this feature for developers aiming to test and develop in local settings. We will bring this suggestion to our team for consideration in future updates. Once this feature becomes available, I will notify you promptly.

In the meantime, if you have any other questions or need assistance with different aspects of the Web3Auth SDK, please feel free to ask.