Skip to main content

WalletConnect v2 Adapter

info

With Web3Auth Web SDK v9.2.0 and above, WalletConnect V2 Adapter can be used to log in with Solana chain namespace as well. Have a look at the example here.

@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?WEB3AUTH_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";

// adding wallet connect v2 adapter
const defaultWcSettings = await getWalletConnectV2Settings(
"solana",
["0x1"],
"YOUR_WALLETCONNECT_PROJECT_ID", // Get your walletconnect project id and register it on the Web3Auth Dashboard in your project add-ons.
);
const walletConnectModal = new WalletConnectModal({
projectId: "YOUR_WALLETCONNECT_PROJECT_ID", // Get your walletconnect project id and register it on the Web3Auth Dashboard in your project add-ons.
});
const walletConnectV2Adapter = new WalletConnectV2Adapter({
adapterSettings: {
qrcodeModal: walletConnectModal,
...defaultWcSettings.adapterSettings,
},
loginSettings: { ...defaultWcSettings.loginSettings },
});

web3auth.configureAdapter(walletConnectV2Adapter);