butr
Connectors

Sui Wallet Standard

Wallet Standard discovery for Sui wallets, via @usebutr/sui.

@usebutr/sui discovers Sui wallets (Slush, Phantom, Suiet, Surf, …) through the Wallet Standard.

Register it

autoDiscovery() from @usebutr/wallets includes Sui. For a Sui-only app, discoverSuiAdapters is a source as-is:

import type { WalletManagerConfig } from "@usebutr/core";
import { WalletManagerProvider } from "@usebutr/react";
import { discoverSuiAdapters } from "@usebutr/sui";

const config: WalletManagerConfig = {
  sources: [discoverSuiAdapters],
  storageKeyPrefix: "my-app",
};

export const Providers = ({ children }: { children: React.ReactNode }) => (
  <WalletManagerProvider config={config}>{children}</WalletManagerProvider>
);

The adapter id is wallet-standard:sui-<wallet name>.

@usebutr/sui lazily imports @wallet-standard/app, an optional peer dependency. A restored Sui wallet can sit in pendingIds for a moment during that warmup; see hydration.

What the adapter defines

Each method exists only when the wallet advertises the matching feature:

MemberWallet Standard featureBehaviour
sendTxsui:signAndExecuteTransactionSigns and executes; resolves the transaction digest.
signMessagesui:signPersonalMessageResolves the signature and the signed bytes.
signTransactionsui:signTransactionSigns without executing; resolves { bytes, signature } for executeTransactionBlock.
disconnectstandard:disconnect
switchChain2+ advertised Sui networksRe-points butr's view; the wallet is not asked to move.
subscribealways, when discoveredAccount and chain changes, and the wallet unregistering.

A transaction is a @mysten/sui Transaction (anything with toJSON()), its JSON string, or BCS bytes. There is no getBalance or getTransactionReceipt: read state with your own SuiClient.

import { SUI_CHAINS } from "@usebutr/core";
import { Transaction } from "@mysten/sui/transactions";

const wallet = useSelectedWallet("sui");

const send = async (tx: Transaction) => {
  if (!wallet?.connector.sendTx) {
    throw new Error("This wallet cannot execute Sui transactions");
  }
  return wallet.connector.sendTx(tx, { chain: SUI_CHAINS.testnet });
};

Chains and accounts

Wallet Standard carries the chain in every call, so options.chain routes one transaction without moving the wallet. The chain must be one the wallet advertises, or the call rejects. The initial chain is sui:mainnet when advertised, else the wallet's first Sui chain. account must be one the wallet exposes; an unknown one rejects.

Signer

getSigner() resolves { kind: "wallet-standard", wallet }. Reach a feature butr does not wrap with getFeature from @usebutr/wallet-standard-shared, typed by the feature shapes @usebutr/sui exports (SuiSignTransactionFeature and so on). See the @mysten/sui integration.

Source: packages/sui/src. See the API reference.