ahana
April 15, 2024, 12:22pm
1
We have tried to integrate web3auth using node js NoModal SDK and I am getting an error on the node js code function (initiateLogin not found) when we try to integrate with the node js route.
SDK Version: “@web3auth /ethereum-provider”: “^8.0.1”,
“@web3auth /node-sdk”: “^3.2.0”,
TomTom
April 15, 2024, 6:09pm
2
hi @ahana
I hope you are doing well. Please check our examples for PnP no-modal with EVM
You don’t need node-sdk package.
If you can’t find the error please share with me some code snippets so I can help you to solve the issue
ahana
April 16, 2024, 9:31am
3
Hi Tom - Thanks for looking into this - I’ve received the below response from my technical team mate for the solution you have provided.
“This is react based application and we want to integrate this in node js SDK. So if you ask him to provide node SDK that would be very helpful for us.”
guru
April 16, 2024, 11:24am
4
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable no-console */
import "react-toastify/dist/ReactToastify.css";
import { getPublicCompressed } from "@toruslabs/eccrypto";
import { CHAIN_NAMESPACES, IProvider, UX_MODE, WALLET_ADAPTERS, WEB3AUTH_NETWORK } from "@web3auth/base";
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
import { Web3AuthNoModal } from "@web3auth/no-modal";
import { OpenloginAdapter } from "@web3auth/openlogin-adapter";
import { useEffect, useState } from "react";
import { toast } from "react-toastify";
// import RPC from "../components/evm.web3";
import RPC from "../components/evm.ethers";
const clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ"; // get from https://dashboard.web3auth.io
function App() {
const [web3auth, setWeb3auth] = useState<Web3AuthNoModal | null>(null);
const [provider, setProvider] = useState<IProvider | null>(null);
const [loggedIn, setLoggedIn] = useState<boolean | null>(false);
This file has been truncated. show original
@ahana please refer this for server side verification
but let us know your requirement and any specific reason for using node js
or try this example if it suits your use case
also go through this guide for choosing the right fit for your requirement
ahana
April 25, 2024, 1:26pm
5
We are trying to not disrupt our onboarding flow. Unfortunately the team says this solution will not work for us. Would it be possible to jump on a call with my team sometime next week. Also, for context, you can try to register to this game to see what we are trying to achieve - https://qz.woof3.xyz/
ahana
May 3, 2024, 8:41am
6
// web3auth routes
const { Web3Auth } = require('@web3auth/node-sdk');
// Initialize Web3Auth - mayur account web3auth
const web3Auth = new Web3Auth({
clientId: "BD_i3rLoAmVRaDAtioTvDKRkFU-kxjBoBYvj7Bhcttuxgnjtb0m97Ghcmqx_y4TvwAg60EQHbFFCZQGrFCpxna0", // Get your Client ID from Web3Auth Dashboard
clientSecret: 'cddef58d2abf1e0d1109c93e471834ba35cfb10a16fd2f0a188b735c70ae6e2f',
redirectUri: 'http://localhost:4013/web3auth/callback',
});
// Route to initiate authentication and connect wallet
app.get('/web3auth/login', async (req, res) => {
try {
// Initiate authentication request
const authUrl = await web3Auth.initiateLogin();
// Redirect user to authentication URL
res.redirect(authUrl);
} catch (error) {
res.status(500).send('Error initiating login: ' + error.message);
}
});
// Callback route after successful authentication
app.get('/web3auth/callback', async (req, res) => {
try {
// Complete authentication and connect wallet
const user = await web3Auth.completeLogin(req.query);
console.log('user-->>>', user)
res.send("User response:" + user);
} catch (error) {
res.status(500).send('Error completing login: ' + error.message);
}
});
// Connect wallet route
app.get('/web3auth/connect-wallet', async (req, res) => {
try {
// Connect wallet
const wallet = await web3Auth.connectWallet(req.session.user);
res.send('Wallet connected successfully: ' + wallet.address);
} catch (error) {
res.status(500).send('Error connecting wallet: ' + error.message);
}
});
// over web3 auth routes
Is this code snippet helpful? We’ve set a call today and hoping to speak with someone from the Tech team to resolve the issue. Cheers!
TomTom
May 10, 2024, 10:36am
7
hi @ahana
Did you test our unity SDK ?
On the other hand maybe these examples can help you in your dApp