butr
API reference

@usebutr/walletconnect

createWalletConnectAdapters, the namespace builders, and the WalletConnect signer.

WalletConnect v2 for EVM, Solana, Sui and Bitcoin mobile wallets. Requires the optional peer dependency @walletconnect/universal-provider, imported on first use.

Factory

createWalletConnectAdapters(options): Promise<Array<WalletAdapter>>

One pairing, one adapter per requested namespace. The adapters are un-paired until the user connects one; hand them to the manager with fromAdapters:

import type { WalletManagerConfig } from "@usebutr/core";
import { fromAdapters } from "@usebutr/core";
import { autoDiscovery } from "@usebutr/wallets";
import { createWalletConnectAdapters } from "@usebutr/walletconnect";

const config: WalletManagerConfig = {
  sources: [
    autoDiscovery(),
    fromAdapters(
      createWalletConnectAdapters({
        metadata: { name: "My dapp", url: "https://my-dapp.example" },
        namespaces: { evm: ["eip155:1", "eip155:137"], svm: [] },
        onPairingUri: showQr,
        projectId: "<your Reown project id>",
      }),
    ),
  ],
};

With more than one namespace each adapter's id and name carry the platform (walletconnect-evm, WalletConnect (EVM)); with one, they stay options.id ?? "walletconnect" and options.name ?? "WalletConnect". The promise rejects for an unknown namespace key or an empty namespaces.

WalletConnectOptions

FieldTypeNotes
projectIdstringRequired. From Reown Cloud.
namespacesPartial<Record<ChainPlatform, ReadonlyArray<string>>>Required. CAIP-2 chains per platform (SVM_CHAINS ids work for Solana). Omit a key to skip it; an empty array uses the builder's defaultChains. The first namespace is required at pairing, the rest optional.
metadataWalletConnectMetadata{ description?; icons?; name?; url? }. Some wallets refuse to pair without name and url.
onPairingUri(uri: string) => voidRender the QR code or deep link; butr ships no QR renderer.
idstringDefault "walletconnect".
namestringDefault "WalletConnect".
iconstringDefault WALLETCONNECT_DEFAULT_ICON.
universalProviderUniversalProviderConstructorReplaces the dynamic import (tests).

Namespace builders

evmNamespace, solanaNamespace, suiNamespace and bitcoinNamespace, and KNOWN_NAMESPACES: Partial<Record<ChainPlatform, WalletConnectNamespaceBuilder>>, the table the factory dispatches through. Polkadot has no namespace yet.

WalletConnectNamespaceBuilder<Adapter> has buildAdapter(input), caipPrefix, chainPlatform, defaultChains, defaultEvents, defaultMethods, and chainAliases?: butr chain ids mapped to the ids sessions use where they differ. solanaNamespace maps SVM_CHAINS ids to genesis-hash ids, so callers pass SVM_CHAINS as on any other transport. buildAdapter takes { chains, icon, id, name, provider, session? }; without a shared session the adapter pairs for its own namespace only.

BuildercaipPrefixdefaultChainsdefaultMethods
evmNamespaceeip155eip155:1eth_sendTransaction, eth_accounts, eth_chainId, eth_getBalance, eth_getTransactionReceipt, personal_sign, wallet_switchEthereumChain
solanaNamespacesolanasolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpsolana_signMessage, solana_signTransaction, solana_signAndSendTransaction
suiNamespacesuisui:mainnetsui_signTransaction, sui_signAndExecuteTransaction, sui_signPersonalMessage
bitcoinNamespacebip122bip122:000000000019d6689c085ae165831e93signMessage, signPsbt, sendTransfer, getAccountAddresses

Signers

The EVM adapter resolves { kind: "eip1193", provider }: an EIP-1193 shim over the session's eip155 side. Importing the package registers the walletconnect kind the other namespaces resolve:

type WalletConnectSigner = {
  chainId: string; // the session's id for the adapter's current chain
  kind: "walletconnect";
  provider: UniversalProviderLike;
};

Pass chainId as provider.request's second argument. Without it, UniversalProvider routes the call to the session's first namespace, so a Solana request in an EVM + Solana session would reach the EVM wallet.

Constants

WALLETCONNECT_DEFAULT_ICON: the default adapter icon.

Types

WalletConnectOptions, WalletConnectMetadata, WalletConnectNamespaceBuilder, WalletConnectSession, UniversalProviderLike, UniversalProviderConstructor.

See the WalletConnect connector for what each namespace defines and how it routes chains.

Source: packages/walletconnect/src/index.ts.