Skip to main content

walletConnectV1

A wallet configurator for Wallet Connect v1 which allows integrating the wallet with React

import { walletConnectV1 } from "@thirdweb-dev/react";

const walletConnectV1Config = walletConnectV1();
customize (optional)

walletConnectV1Config contains the default config for metadata and UI. you can optionally choose to override the defaults to customize the wallet. Learn more about these configs

const walletConnectV1Config = walletConnectV1({ ... });

// override metadata
walletConnectV1Config.meta.name = "..."; // change the name
walletConnectV1Config.meta.iconURL = "..."; // change the icon
walletConnectV1Config.meta.urls = {
// change urls to download the wallet on various platforms
android: "https://...",
ios: "https://...",
chrome: "https://...",
firefox: "https://...",
};

// override connection UI
walletConnectV1Config.connectUI = WalletConnectV1ConnectUI; // react component

// custom selection UI
walletConnectV1Config.selectUI = WalletConnectV1SelectUI; // react component

Once the config is ready, you can use it with ConnectWallet component or useConnect hook as shown below

// add to ThirdwebProvider to add it in ConnectWallet's modal
<ThirdwebProvider supportedWallets={[walletConnectV1Config]} />;

// or use it with useConnect hook
const connect = useConnect();
connect(walletConnectV1Config, { ... });

Usage with ConnectWallet

To allow users to connect to this wallet using the ConnectWallet component, you can add it to ThirdwebProvider's supportedWallets prop.

<ThirdwebProvider supportedWallets={[walletConnectV1()]}>
<YourApp />
</ThirdwebProvider>

Usage with useConnect

you can use the useConnect hook to programmatically connect to the wallet without using the ConnectWallet component.

The wallet also needs to be added in ThirdwebProvider's supportedWallets if you want the wallet to auto-connect on next page load.

const walletConnectV1Config = walletConnectV1();

function App() {
const connect = useConnect();

const handleConnect = async () => {
await connect(walletConnectV1Config, connectOptions);
};

return <div> ... </div>;
}

connectOptions

{ chainId?: string } | undefined
chainId (optional)

If chainId is provided, wallet will be connected and immediately switch to network with given chainId.

Chain object corresponding to this chainId from @thirdweb-dev/chains package must be specified in ThirdwebProvider's supportedChains prop as shown below

import { Polygon } from "@thirdweb-dev/chains";
import { ThirdwebProvider } from "@thirdweb-dev/react";

export function YourApp() {
return (
<ThirdwebProvider supportedChains={[Polygon]}>
<App />
</ThirdwebProvider>
);
}