Skip to main content

walletconnection

Wallet Connection

The WalletConnection component provides a modal for users to connect their cryptocurrency wallets using MetaMask, WalletConnect, or Coinbase Wallet. It supports theme customization and displays the connected wallet address.

Installation

Ensure you have the necessary dependencies installed:

  npm i @brightcodeui/beta-ui

Basic Example

Props

PropTypeDescription
isOpenbooleanControls the visibility of the modal.
onClose() => voidCallback function to close the modal.
onConnect(walletType: string) => Promise<string>Function to handle wallet connection. Returns wallet address.
onDisconnect() => voidFunction to disconnect the wallet.
theme`"light""dark"`
accentColorstringDefines the accent color of the modal. Optional.

Theming

You can switch between light and dark themes by setting the theme prop:

    <WalletConnection 
isOpen={isOpen}
onClose={onClose}
onConnect={onConnect}
onDisconnect={onDisconnect}
theme="dark"
/>

Custom Accent Color

You can pass a custom accent color to style the modal:

    <WalletConnection 
isOpen={isOpen}
onClose={onClose}
onConnect={onConnect}
onDisconnect={onDisconnect}
accentColor="purple"
/>

Error Handling

If the connection fails, an error message is displayed. You can simulate a failed connection like this:

    const handleConnect = async () => {
throw new Error("Failed to connect wallet.");
};

Now you can integrate WalletConnection into your Frontend Project applications to provide a seamless wallet connection experience!