Please provide the following details too when asking for help in this category:
-
SDK Version: 6.1.4
-
Platform: React js
-
Browser Console Screenshots:
-
Related to Custom Authentication? Please provide the following info too: (Optional)
- Verifier Name:
- JWKS Endpoint:
- Sample idToken(JWT)
Please provide the Web3Auth initialization and login code snippet below:
if (connectedAddress) {
try {
const provider = new ethers.providers.Web3Provider(
web3auth.provider
);
let nonce = “”;
await provider
?.getTransactionCount(connectedAddress)
.then(async (result) => {
nonce = CryptoJS.AES.encrypt(
JSON.stringify(result),
“DASecretKey”
).toString();
});
console.log(“siteUrl”, siteUrl, “nonce”, nonce);
const signer = provider.getSigner();
const originalMessage = `Welcome to Digital Arms!\n\nClick to sign in and accept the Digital Arms Terms of Service: ${siteUrl}/\n\nThis request will not trigger a blockchain transaction or cost any gas fees.\n\nYour authentication status will reset after 24 hours.\n\nWallet address:\n${connectedAddress}\n\nNonce:\n${nonce}`;
const signature = await signer.signMessage(originalMessage);
if (signature) {
userAuth(
connectedAddress,
signature,
originalMessage,
user?.email ? user.email : ""
);
} else {
console.log("disconnect wallet");
await web3auth?.logout();
//await onboard.disconnectWallet({ label: wallets[0].label });
NotificationManager.error(
"User Denied Signature",
"",
NOTIFICATION_DELAY
);
setTimeout(() => {
window.location.reload();
}, 1000);
refreshState();
}
console.log("signature", signature);
} catch (error) {
await web3auth?.logout();
console.log(
"denied message is--->",
error.message,
typeof error.message
);
}