@solana/web3.js
Connection for reads, Transaction/SystemProgram builders, Wallet Standard features for signing.
Legacy. @solana/web3.js v1 is in maintenance mode. For new apps, prefer
framework-kit (the recommended modern stack),
gill (ergonomic, for most apps), or
@solana/kit (low-level). This page is kept for apps still on v1.
butr discovers Solana Wallet Standard wallets and manages the connection.
@solana/web3.js provides Connection for chain reads and the
Transaction / SystemProgram builders; signing and sending flow through the
wallet's native Wallet Standard features.
Get the signer
getSigner() on an SVM adapter returns the WalletStandardWallet:
import type {
SolanaSignAndSendTransactionFeature,
SolanaSignMessageFeature,
WalletStandardWallet,
} from "@usebutr/svm";
const walletStd = (await wallet.connector.getSigner()) as WalletStandardWallet;Read chain state
import { Connection } from "@solana/web3.js";
const connection = new Connection("https://api.devnet.solana.com", "confirmed");
const lamports = await connection.getBalance(publicKey);Sign a message
const feature = walletStd.features["solana:signMessage"] as SolanaSignMessageFeature | undefined;
if (!feature) throw new Error("Wallet does not advertise solana:signMessage");
const account = walletStd.accounts[0];
const [output] = await feature.signMessage({ account, message });
// output.signature: Uint8ArrayBuild and send a transaction
Build with @solana/web3.js, submit through
solana:signAndSendTransaction:
const feature = walletStd.features["solana:signAndSendTransaction"] as
| SolanaSignAndSendTransactionFeature
| undefined;
if (!feature) throw new Error("Wallet does not advertise solana:signAndSendTransaction");
const account = walletStd.accounts[0];
const [output] = await feature.signAndSendTransaction({
account,
chain: "solana:devnet",
transaction: new Uint8Array(serialisedTx),
});Feature-detect every time (if (!feature) throw). Wallets advertise the Wallet Standard features
unevenly; gate UI on wallet.connector.capabilities.sendTransaction / .signMessage.
Source: apps/demo-with-solana-web3js/src/app.tsx in the butr
repository.
Targets Solana devnet. Run pnpm dev --filter=demo-with-solana-web3js → http://localhost:5177.