I have the same issue. also have a vanilla js script like alex… are there some additional requirements ? is it working only on mainnet i didnt try that yet
Hi @darkobas,
I hope you are doing well. Could you please create a new post sharing the packages, versions, and some code snippets?
Thanks!
Hi TomTom,
Here are the packages we use and our initializations (we use vanilla js).
<script src="https://cdn.jsdelivr.net/npm/buffer@6"></script>
<script src="https://cdn.jsdelivr.net/npm/@web3auth/modal@8.5.0"></script>
<script src="https://cdn.jsdelivr.net/npm/@web3auth/ethereum-provider@8.5.0"></script>
<script src="https://cdn.jsdelivr.net/npm/@web3auth/wallet-services-plugin@8.5.0"></script>
<script src="https://cdn.jsdelivr.net/npm/@web3auth/metamask-adapter@8.5.0"></script>
<script src="https://cdn.jsdelivr.net/npm/web3@4.8.0/dist/web3.min.js"></script>
(async function init() {
console.log("Web3Auth init");
const clientId = "xxxxxxxxxxxxxxxxxxxxxxxx";
// Init web3auth
const whiteLabel = {
appName: 'XXXXXX',
defaultLanguage: "en",
logoLight: "https://web3auth.io/images/web3auth-logo.svg",
logoDark: "https://web3auth.io/images/web3auth-logo---Dark.svg",
mode: "light",
}
const chainConfig = {
chainNamespace: "eip155",
chainId: "0xaa36a7", // Please use 0x1 for Mainnet
rpcTarget: "https://sepolia.infura.io/v3/xxxxxxx", // "https://rpc.ankr.com/eth_sepolia"
displayName: "Seopolia Testnet",
blockExplorer: "https://sepolia.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum Sepolia",
uiConfig: whiteLabel
};
const privateKeyProvider = new window.EthereumProvider.EthereumPrivateKeyProvider({ config: { chainConfig } });
web3auth = new window.Modal.Web3Auth({
clientId,
privateKeyProvider,
web3AuthNetwork: "sapphire_devnet"
});
// Add metamask adapter
const metamaskAdapter = new window.MetamaskAdapter.MetamaskAdapter({
clientId,
sessionTime: 3600, // 1 hour in seconds
web3AuthNetwork: "sapphire_devnet",
chainConfig: {
chainNamespace: "eip155",
chainId: "0xaa36a7",
rpcTarget: "https://sepolia.infura.io/v3/xxxxxxxxxxxxx" // This is the public RPC we have added, please pass on your own endpoint while creating an app
}
});
web3auth.configureAdapter(metamaskAdapter);
// Add wallet service plugin
walletServicesPlugin = new window.WalletServicesPlugin.WalletServicesPlugin();
web3auth.addPlugin(walletServicesPlugin); // Add the plugin to web3auth
await web3auth.initModal();
console.log("Web3Auth instance is", web3auth);
})();
async function showWalletUi() {
if (walletServicesPlugin.status == "connected") { // "always not connected"
await walletServicesPlugin.showWalletUi();
}
}
Hope it helps you find a solution. Thanks for your help.
hi @alex5,
Please check out the VanillaJS modal example with the wallet service that is functional. Let me know if you need further assistance.
its working for me… i shouldnt have tested with a metamask login
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.