# @solana/web3.js (/integrations/solana-web3js)



<Callout type="warn">
  **Legacy.** `@solana/web3.js` v1 is in maintenance mode. For new apps, prefer
  [framework-kit](/integrations/solana-framework-kit) (the recommended modern stack),
  [gill](/integrations/gill) (ergonomic, for most apps), or
  [`@solana/kit`](/integrations/solana-kit) (low-level). This page is kept for apps still on v1.
</Callout>

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 [#get-the-signer]

`getSigner()` on an SVM adapter returns the `WalletStandardWallet`:

```ts
import type {
  SolanaSignAndSendTransactionFeature,
  SolanaSignMessageFeature,
  WalletStandardWallet,
} from "@usebutr/svm";

const walletStd = (await wallet.connector.getSigner()) as WalletStandardWallet;
```

## Read chain state [#read-chain-state]

```ts
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 [#sign-a-message]

```ts
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: Uint8Array
```

## Build and send a transaction [#build-and-send-a-transaction]

Build with `@solana/web3.js`, submit through
`solana:signAndSendTransaction`:

```ts
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),
});
```

<Callout type="warn">
  Feature-detect every time (`if (!feature) throw`). Wallets advertise the Wallet Standard features
  unevenly; gate UI on `wallet.connector.capabilities.sendTransaction` / `.signMessage`.
</Callout>

<Callout type="info">
  **Source:** `apps/demo-with-solana-web3js/src/app.tsx` in the [butr
  repository](https://github.com/pedroapfilho/usebutr/tree/main/apps/demo-with-solana-web3js).
  Targets Solana devnet. Run `pnpm dev --filter=demo-with-solana-web3js` → `http://localhost:5177`.
</Callout>
