Describe the bug
The connected event is not fired after a successful login redirect using web3auth version 6.1.7 in a Next.js application.
To Reproduce
Steps to reproduce the behavior:
Click connect here. https://one-grid-git-development-onegrid.vercel.app/rickyrazu
You will be redirected to the external authentication provider (e.g., MetaMask or another Web3 wallet).
Complete the login process and grant necessary permissions.
After successful authentication, you should be redirected back to the application.
Check console => There are logs in it, some times if you go to main page (https://one-grid-git-development-onegrid.vercel.app) and click connect there it works and you see the connected event fired.
Looking at the error it looks like you have not specified the web3AuthNetwork parameter during the Web3Auth No-Modal initialization ? I’ll paste a snippet here for your reference on where should it go. Please mention the network you are on Testnet, Mainnet, etc whichever you have setup up on the dashboard should match with the network in your code too.
const web3auth = new Web3AuthNoModal({
clientId: "", // Get your Client ID from Web3Auth Dashboard
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0x1",
displayName: "Ethereum Mainnet",
blockExplorer: "https://etherscan.io",
ticker: "ETH",
tickerName: "Ethereum",
rpcTarget: "https://rpc.ankr.com/eth", // This is the mainnet RPC we have added, please pass on your own endpoint while creating an app
},
web3AuthNetwork: "mainnet", // mainnet, aqua, cyan or testnet
});
Hi team, following-up on Francis. we have an important launch this Thursday. Can we jump into a call or chat to quickly explore if the issue is on our side our your side?
@s-nakamatsu That’s not the case. I was aiming to re-create the exact scenario the user was facing, just to see if I get the same issue. The user on 5.x on their prod environment, I was reminded of that later and I downgraded the version and made changes accordingly, hence the commit.
The issue that was occurring in my application was due to incorrect code.
Specifically, the timing of calling init() was incorrect.
The problem arose from mistakenly calling init() before the appropriate point, which should have been done after registering the event handler as shown below.
The library version didn’t seem to matter, in my case.