- SDK Version: 7.1.0
- Platform: html/js (vanilla js only)
I think it is not initializing. I copied and pasted from the builder. What’s the problem? What I missed?
let web3auth = null;
let provider = null;
(async function init() {
const clientId = " "; // get your clientId from https://dashboard.web3auth.io
const web3auth = new Web3Auth({
clientId,
web3AuthNetwork: "testnet", // mainnet, aqua, cyan or testnet
chainConfig: {
chainNamespace: "eip155",
chainId: "0x1",
rpcTarget: "https://rpc.ankr.com/eth", // This is the public RPC we have added, please pass on your own endpoint while creating an app
},
uiConfig: {
theme: "dark",
loginMethodsOrder: ["facebook", "google"],
appLogo: "https://web3auth.io/images/w3a-L-Favicon-1.svg", // Your App Logo Here
}
});
const openloginAdapter = new OpenloginAdapter({
loginSettings: {
mfaLevel: "default", // Pass on the mfa level of your choice: default, optional, mandatory, none
},
adapterSettings: {
whiteLabel: {
name: "Your app Name",
logoLight: "https://web3auth.io/images/w3a-L-Favicon-1.svg",
logoDark: "https://web3auth.io/images/w3a-D-Favicon-1.svg",
defaultLanguage: "en",
dark: true, // whether to enable dark mode. defaultValue: false
},
}
});
web3auth.configureAdapter(openloginAdapter);
await web3auth.initModal({
modalConfig: {
[WALLET_ADAPTERS.OPENLOGIN]: {
label: "openlogin",
loginMethods: {
google: {
name: "google login",
logoDark: "url to your custom logo which will shown in dark mode",
},
facebook: {
// it will hide the facebook option from the Web3Auth modal.
showOnModal: false,
},
},
// setting it to false will hide all social login methods from modal.
showOnModal: true,
},
},
});
})();
$("#login").click(async function (event) {
try {
const web3authProvider = await web3auth.connect();
} catch (error) {
console.error(error.message);
}
});