Get Default External Adapters doesn't work with my project id, only getInjectedAdapters works

getDefaultExternalAdapters doesn’t work with my project id, only getInjectedAdapters works.

I even made sure to use the same versions as the sample:

@web3auth/base”: “^9.2.2”,
@web3auth/default-evm-adapter”: “^9.2.2”,
@web3auth/ethereum-provider”: “^9.2.2”,
@web3auth/modal”: “^9.2.2”,

Here’s the code:

/* eslint-disable no-console */

“use client”;

import { CHAIN_NAMESPACES, IAdapter, IProvider, WEB3AUTH_NETWORK } from “@web3auth/base”;
import { EthereumPrivateKeyProvider } from “@web3auth/ethereum-provider”;
import { getDefaultExternalAdapters, getInjectedAdapters } from “@web3auth/default-evm-adapter”;
import { Web3Auth, Web3AuthOptions } from “@web3auth/modal”;
import { useEffect, useState } from “react”;
import { Button } from “@/components/ui/button”;

// import RPC from “./ethersRPC”;
import RPC from “./viemRPC”;
// import RPC from “./web3RPC”;

const clientId = “I use my prod client id here. It works when I use the one from sample code”; // get from https://dashboard.web3auth.io

const chainConfig = {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: “0x89”,
rpcTarget: “https://rpc.ankr.com/polygon”,
displayName: “Polygon Mainnet”,
blockExplorerUrl: “https://polygon.etherscan.io”,
ticker: “POL”,
tickerName: “Polygon Ecosystem Token”,
};

const privateKeyProvider = new EthereumPrivateKeyProvider({
config: { chainConfig },
});

const web3AuthOptions: Web3AuthOptions = {
clientId,
// web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET,
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
privateKeyProvider,
};
const web3auth = new Web3Auth(web3AuthOptions);

console.log("Web3auth: ", web3auth);

function App() {
const [provider, setProvider] = useState<IProvider | null>(null);
const [loggedIn, setLoggedIn] = useState(false);

useEffect(() => {
const init = async () => {
try {
const adapters = await getDefaultExternalAdapters({ options: web3AuthOptions });
adapters.forEach((adapter: IAdapter) => {
const web3authObject = web3auth.configureAdapter(adapter);
console.log(web3authObject);
});
// IMP START - SDK Initialization
await web3auth.initModal();
setProvider(web3auth.provider);

    if (web3auth.connected) {
      setLoggedIn(true);
    }
  } catch (error) {
    console.error(error);
  }
};

init();

}, []);

const login = async () => {
const web3authProvider = await web3auth.connect();
setProvider(web3authProvider);
if (web3auth.connected) {
setLoggedIn(true);
}
};

const getUserInfo = async () => {
const user = await web3auth.getUserInfo();
uiConsole(user);
};

const logout = async () => {
await web3auth.logout();
setProvider(null);
setLoggedIn(false);
uiConsole(“logged out”);
};

// Check the RPC file for the implementation
const getAccounts = async () => {
if (!provider) {
uiConsole(“provider not initialized yet”);
return;
}
const address = await RPC.getAccounts(provider);
uiConsole(address);
};

const getBalance = async () => {
if (!provider) {
uiConsole(“provider not initialized yet”);
return;
}
const balance = await RPC.getBalance(provider);
uiConsole(balance);
};

const signMessage = async () => {
if (!provider) {
uiConsole(“provider not initialized yet”);
return;
}
const signedMessage = await RPC.signMessage(provider);
uiConsole(signedMessage);
};

const sendTransaction = async () => {
if (!provider) {
uiConsole(“provider not initialized yet”);
return;
}
uiConsole(“Sending Transaction…”);
const transactionReceipt = await RPC.sendTransaction(provider);
uiConsole(transactionReceipt);
};

const getConnectedAdapterName = async () => {
if (!provider) {
uiConsole(“provider not initialized yet”);
return;
}
uiConsole(“getConnectedAdapterName…”);
const adapter = web3auth.connectedAdapterName;
uiConsole(adapter);
};

function uiConsole(…args: any[]): void {
const el = document.querySelector(“#console>p”);
if (el) {
el.innerHTML = JSON.stringify(args || {}, null, 2);
console.log(…args);
}
}

const loggedInView = (
<>




Get User Info




Get Accounts




Get Balance




Sign Message




Send Transaction




getConnectedAdapterName




Log Out



</>
);

const unloggedInView = (



Login


);

return (




Web3Auth
{" "}

& NextJS Quick Start

  <div className="grid">{loggedIn ? loggedInView : unloggedInView}</div>
  <div id="console" style={{ whiteSpace: "pre-line" }}>
    <p style={{ whiteSpace: "pre-line" }}></p>
  </div>

  <footer className="footer">
    <a
      href="https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/web-modal-sdk/quick-starts/nextjs-modal-quick-start"
      target="_blank"
      rel="noopener noreferrer"
    >
      Source code
    </a>
    <a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FWeb3Auth%2Fweb3auth-pnp-examples%2Ftree%2Fmain%2Fweb-modal-sdk%2Fquick-starts%2Fnextjs-modal-quick-start&project-name=w3a-nextjs-modal&repository-name=w3a-nextjs-modal">
      <img src="https://vercel.com/button" alt="Deploy with Vercel" />
    </a>
  </footer>
</div>

);
}

export default App;

Hi Augustin Chan! Thank you for providing a detailed description of your issue. Let’s get to work on this!

Here’s a summary of the information you’ve shared regarding the problem with getDefaultExternalAdapters not working with your project ID:

Issue Details:

  • SDK Details: PnP Web SDK
  • Issue: getDefaultExternalAdapters doesn’t work with my project ID; only getInjectedAdapters works.

SDK Version Information:

  • @web3auth/base: ^9.2.2
  • @web3auth/default-evm-adapter: ^9.2.2
  • @web3auth/ethereum-provider: ^9.2.2
  • @web3auth/modal: ^9.2.2

Code Snippet

You provided a clear code snippet where the issue occurs.

Suggested Next Steps:

  1. Double-check that your project ID is correctly set, and that it matches what is configured in the Web3Auth dashboard.
  2. Verify if there are any permissions or settings related to your project in the dashboard that might impact using the getDefaultExternalAdapters.
  3. If there’s any related documentation or example that you might have missed out on, it’s worth revisiting.

If the issue persists, would you mind sharing any console errors or logs that appear when you try to use getDefaultExternalAdapters? This information will help our support team investigate further.

Feel free to attach any relevant screenshots too—they might contain helpful context!

Looking forward to assisting you further!

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.

It just gives a generic invalid project id error. There’s no dialog box to login, only a searchable selection dropdown to select from 390+ wallets, but it doesn’t detect the wallets I have.

WalletInitializationError: Invalid params passed in, Invalid wallet connect project id. Please configure it on the dashboard
at WalletInitializationError.fromCode (index.js:73:12)
at WalletInitializationError.invalidParams (index.js:108:38)
at eval (modalManager.js:264:567)
at Array.map ()
at Web3Auth.initModal (modalManager.js:114:54)
at async init (page.tsx:59:9)