Skip to main content

WalletConnect v2 Adapter

@web3auth/wallet-connect-v2-adapter

Wallet connect v2 adapter allows you to log in with wallet connect v2. You can read more about Walletconnect here.

Basic Details

Adapter Name: wallet-connect-v2

Package Name: @web3auth/wallet-connect-v2-adapter

chainNamespace: EIP155

Installation

npm install --save @web3auth/wallet-connect-v2-adapter

Arguments

Parametertype
adapterSettings?IAdapterSettings
chainConfig?CustomChainConfig
sessionTime?number
clientId?string
web3AuthNetwork?OPENLOGIN_NETWORK_TYPE
useCoreKitKey?boolean

Custom Chain Config

chainConfig

warning

While you can pass your chainConfig here, it is not required since you can directly pass it over to the Web3Auth/ Web3AuthNoModal configuration while instantiating it.

Read more about it in their respective sections:

warning

If you pass chainConfig in an Adapter, it overwrites the chainConfig passed over to the Web3Auth/ Web3AuthNoModal constructor.

IAdapter Settings

adapterSettings

interface IAdapterSettings {
walletConnectInitOptions?: SignClientTypes.Options;
qrcodeModal?: IQRCodeModal;
}

interface IQRCodeModal {
openModal: (options?: OpenOptions) => Promise<void>;
closeModal: () => void;
}
interface OpenOptions {
uri: string;
chains?: string[];
}

getWalletConnectV2Settings

You can get walletConnectV2 settings by calling the getWalletConnectV2Settings() function with its required arguments.

Arguments

Parametertype
namespaceChainNamespaceType, e.g. (eip155)
chainIdsstring[] e.g. ["1"]
projectIDWalletConnect Project ID, get one from https://cloud.walletconnect.com

Example

import { WalletConnectModal } from "@walletconnect/modal";
import { getWalletConnectV2Settings, WalletConnectV2Adapter } from "@web3auth/wallet-connect-v2-adapter";

const defaultWcSettings = await getWalletConnectV2Settings("eip155", ["1"], "04309ed1007e77d1f119b85205bb779d");
const walletConnectModal = new WalletConnectModal({ projectId: "04309ed1007e77d1f119b85205bb779d" });
const walletConnectV2Adapter = new WalletConnectV2Adapter({
adapterSettings: { qrcodeModal: walletConnectModal, ...defaultWcSettings.adapterSettings },
loginSettings: { ...defaultWcSettings.loginSettings },
});

web3auth.configureAdapter(walletConnectV2Adapter);