WalletConnect v1
Prompt users to connect to your app with WalletConnect v1.
Usage
import { WalletConnectV1 } from "@thirdweb-dev/wallets";
const wallet = new WalletConnectV1();
wallet.connect();
Configuration
Optionally, provide a configuration object when instantiating the WalletConnectV1
class.
chains
Provide an array of chains you want to support.
Must be an array of Chain
objects, from the @thirdweb-dev/chains
package.
Defaults to our default chains.
import { WalletConnectV1 } from "@thirdweb-dev/wallets";
import { Ethereum } from "@thirdweb-dev/chains";
const walletWithOptions = new WalletConnectV1(
{
chains: [Ethereum],
},
);
dappMetadata
Information about your app that the wallet will display when your app tries to connect to it.
Must be an object containing name
, url
, description
and logoUrl
properties.
import { WalletConnectV1 } from "@thirdweb-dev/wallets";
const walletWithOptions = new WalletConnectV1({
dappMetadata: {
name: "thirdweb powered dApp",
url: "https://thirdweb.com",
description: "thirdweb powered dApp",
logoUrl: "https://thirdweb.com/favicon.ico",
},
});
qrcode
Whether to display the Wallet Connect QR code Modal for connecting to MetaMask on mobile if MetaMask is not injected.
Must be a boolean
. Defaults to true
.
import { WalletConnectV1 } from "@thirdweb-dev/wallets";
const walletWithOptions = new WalletConnectV1(
{
qrcode: false,
},
);
walletStorage
Some wallets need to store data in persistent storage. This is the storage that will be used for that.
Must be an object conforming to the AsyncStorage
interface:
export interface AsyncStorage {
getItem(key: string): Promise<string | null>;
setItem(key: string, value: string): Promise<void>;
removeItem(key: string): Promise<void>;
}
Example:
import { WalletConnectV1 } from "@thirdweb-dev/wallets";
const walletWithOptions = new WalletConnectV1(
{
walletStorage: {
getItem: (key) => {
// Implement your own storage logic here
},
removeItem: (key) => {
// Implement your own storage logic here
},
setItem: (key, value) => {
// Implement your own storage logic here
},
},
},
);
walletId
An ID for the wallet used to store the wallet in the walletStorage
.
import { WalletConnectV1 } from "@thirdweb-dev/wallets";
const walletWithOptions = new WalletConnectV1(
{
walletId: "wallet-id",
},
);
Methods
Inherhits all the public methods from the AbstractClientWallet
class.