createWalletConnectClient
Creates a new WalletConnect client for interacting with another application.
import { createWalletConnectClient } from "thirdweb/wallets"; const client = await createWalletConnectClient({ wallet: wallet, client: client,});
Pass custom handlers:
import { createWalletConnectClient } from "thirdweb/wallets"; const client = await createWalletConnectClient({ wallet: wallet, client: client, requestHandlers: { eth_signTransaction: ({ account, chainId, params }) => { // handle transaction signing }, },});
Pass connect and disconnect callbacks:
import { createWalletConnectClient } from "thirdweb/wallets"; const client = await createWalletConnectClient({ wallet: wallet, client: client, onConnect: (session) => { console.log("Connected to WalletConnect", session); }, onDisconnect: (session) => { console.log("Disconnected from WalletConnect", session); },});
function createWalletConnectClient(options: { appMetadata?: AppMetadata; chains?: Array<{ readonly blockExplorers?: Array<{ apiUrl?: string; name: string; url: string; }>; readonly experimental?: { increaseZeroByteCount?: boolean }; readonly faucets?: Array<string>; readonly icon?: Icon; readonly id: number; readonly name?: string; readonly nativeCurrency?: { decimals?: number; name?: string; symbol?: string; }; readonly rpc: string; readonly testnet?: true; }>; onError?: (error: Error) => void; projectId?: string; requestHandlers?: { eth_sendRawTransaction?: (_: { chainId: number; params: WalletConnectRawTransactionRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_sendTransaction?: (_: { chainId: number; params: WalletConnectTransactionRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_sign?: (_: { params: WalletConnectSignRequestPrams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_signTransaction?: (_: { params: WalletConnectTransactionRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_signTypedData?: (_: { params: WalletConnectSignTypedDataRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_signTypedData_v4?: (_: { params: WalletConnectSignTypedDataRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; personal_sign?: (_: { params: WalletConnectSignRequestPrams; }) => Promise<`0x${string}` | WalletConnectRequestError>; wallet_addEthereumChain?: (_: { params: WalletConnectAddEthereumChainRequestParams; }) => Promise<`0x${string}`>; wallet_switchEthereumChain?: (_: { params: WalletConnectSwitchEthereumChainRequestParams; }) => Promise<`0x${string}`>; };
The options to use to create the WalletConnect client.
let options: { appMetadata?: AppMetadata; chains?: Array<{ readonly blockExplorers?: Array<{ apiUrl?: string; name: string; url: string; }>; readonly experimental?: { increaseZeroByteCount?: boolean }; readonly faucets?: Array<string>; readonly icon?: Icon; readonly id: number; readonly name?: string; readonly nativeCurrency?: { decimals?: number; name?: string; symbol?: string; }; readonly rpc: string; readonly testnet?: true; }>; onError?: (error: Error) => void; projectId?: string; requestHandlers?: { eth_sendRawTransaction?: (_: { chainId: number; params: WalletConnectRawTransactionRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_sendTransaction?: (_: { chainId: number; params: WalletConnectTransactionRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_sign?: (_: { params: WalletConnectSignRequestPrams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_signTransaction?: (_: { params: WalletConnectTransactionRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_signTypedData?: (_: { params: WalletConnectSignTypedDataRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; eth_signTypedData_v4?: (_: { params: WalletConnectSignTypedDataRequestParams; }) => Promise<`0x${string}` | WalletConnectRequestError>; personal_sign?: (_: { params: WalletConnectSignRequestPrams; }) => Promise<`0x${string}` | WalletConnectRequestError>; wallet_addEthereumChain?: (_: { params: WalletConnectAddEthereumChainRequestParams; }) => Promise<`0x${string}`>; wallet_switchEthereumChain?: (_: { params: WalletConnectSwitchEthereumChainRequestParams; }) => Promise<`0x${string}`>; };};
The WalletConnect client. Use this client to connect to a WalletConnect URI with createWalletConnectSession.