Connect Wallet

npm

npm install 0xsodium ethers

yarn

yarn add 0xsodium ethers

pnpm

pnpm install 0xsodium ethers
import { sodium } from "0xsodium";

// calling wallet with iframe
const wallet = await sodium.initWallet("polygon", {
    walletAppURL: "https://sodium-two.vercel.app",
    transports: {
        iframeTransport: {
            enabled: true
        }
    }
});

// auto connect wallet in sodium gallery
const wallet = await sodium.initWallet("polygon", {
    walletAppURL: "https://sodium-two.vercel.app",
    transports: {
        iframeTransport: {
            enabled: true,
        },
        appTransport: {
            enabled: true
        }
    }
});

After instantiation, you can call the connect method to connect to the wallet

const connectDetails = await wallet.connect({
  app: "Your Dapp name",
  authorize: true,
});

console.log("user accepted connect?", connectDetails.connected);

Last updated