@usebutr/sui
v4.0.0
Published
Wallet Standard adapter for butr (Sui).
Maintainers
Readme
@usebutr/sui
Wallet Standard adapter for butr (Sui).
Part of butr, a multi-chain wallet discovery and connection-state library. Your application owns the picker UI and chain client.
Install
npm install @usebutr/react @usebutr/core @usebutr/sui zustand @wallet-standard/appReact 19 is a peer dependency of the provider. Discovery does not render a connect modal; add your picker as the provider child. @wallet-standard/app is required for Wallet Standard discovery.
Usage
import type { ReactNode } from "react";
import type { WalletManagerConfig } from "@usebutr/core";
import { discoverSuiAdapters } from "@usebutr/sui";
import { WalletManagerProvider } from "@usebutr/react";
// Every `discover*Adapters` export is a wallet source as-is.
const config: WalletManagerConfig = { sources: [discoverSuiAdapters] };
export const WalletProvider = ({ children }: { children: ReactNode }) => (
<WalletManagerProvider config={config}>{children}</WalletManagerProvider>
);Each adapter defines sendTx (sui:signAndExecuteTransaction, resolves the digest), signMessage (sui:signPersonalMessage) and signTransaction (resolves { bytes, signature } for executeTransactionBlock) only when the wallet advertises the matching feature, and switchChain only when it advertises more than one Sui network. Transactions are a @mysten/sui Transaction, its JSON string, BCS bytes, or their base64. Wallet Standard carries the chain per call, so options.chain routes one transaction without moving the wallet. Balances and receipts need your own SuiClient. Check a method's presence before calling it:
import type { ConnectedWallet, SuiTransactionInput } from "@usebutr/core";
import { SUI_CHAINS } from "@usebutr/core";
export const send = async (wallet: ConnectedWallet<"sui">, transaction: SuiTransactionInput) => {
if (!wallet.connector.sendTx) {
throw new Error(`${wallet.connector.name} cannot send Sui transactions`);
}
return wallet.connector.sendTx(transaction, {
account: wallet.account,
chain: SUI_CHAINS.testnet,
});
};An account the wallet does not expose, or a chain it does not advertise, rejects. getSigner() resolves { kind: "wallet-standard", wallet }: reach any other feature with getFeature from @usebutr/wallet-standard-shared and the feature types this package exports. Chain registries (SUI_CHAINS, SUI_CHAINS_LIST) come from @usebutr/core.
@usebutr/sui/transaction exports prepareSuiTransaction(tx), which reads
any SuiTransactionInput into the string wallets read with Transaction.from
and, when the input carried them, its BCS bytes, plus
serializeEd25519Signature(signature, publicKey). Wallet Standard,
WalletConnect and Ledger share it; the entry point loads no discovery code.
Documentation
License
MIT, copyright 2026 Pedro Filho.
