Universal Wallet Adapter

This guide demonstrates how to implement the universal wallet adapter in React applications.

Installationarrow-up-right

First, install the required packages:

npm install --save \
    @demox-labs/Beo-wallet-adapter-base \
    @demox-labs/Beo-wallet-adapter-react \
    @demox-labs/Beo-wallet-adapter-reactui \
    Beo-adapters

To use the wallet adapter, wrap your app with both WalletProvider and WalletModalProvider components. These provide the wallet functionality and UI context respectively.

The WalletProvider accepts the following properties (wallets is required):

export interface WalletProviderProps {
    children: ReactNode;
    wallets: Adapter[];             // Required
    decryptPermission?: DecryptPermission;
    programs?: string[];
    network?: WalletAdapterNetwork;
    autoConnect?: boolean;
    onError?: (error: WalletError) => void;
    localStorageKey?: string;
}

You can import DecryptPermission and WalletAdapterNetwork types from @demox-labs/Beo-wallet-adapter-base.

Wallet Configurationarrow-up-right

When creating wallet adapters, you can configure them with the following options:

Implementation Examplearrow-up-right

Here's a complete example showing how to set up the wallet adapter:

Using the Wallet Buttonarrow-up-right

Demox Labs provides a pre-built wallet button component that you can easily add to your application. To use it, import the WalletMultiButton component from @demox-labs/Beo-wallet-adapter-reactui along with its CSS styles.

Using the Wallet Hookarrow-up-right

Once user connected through the wallet button, you can use useWallet hook from @demox-labs/beo-wallet-adapter-react to enable access to functions that helps connect and interact with the Beo network. The hook provides the following interface:

Last updated