Full lesson
wallet-adapter
Modular TypeScript wallet adapters and components for Solana applications.
- Original
- anza-xyz/wallet-adapter
- SuperStack fork
- Blockchains/wallet-adapter @
5f33bc6 - Stars
- 2,032
- Last push (original)
- 2026-10-06
- Languages
- TypeScript, CSS, JavaScript, HTML
- Detected stack
- Next.jsweb3.js
- Categories
- Wallets & Identity
- Licence
- Apache-2.0
- Homepage
- https://anza-xyz.github.io/wallet-adapter/
Architecture
146 source files. By extension: .ts ×107, .tsx ×38, .js ×1.
| Top-level directory | Source files |
|---|---|
packages | 146 |
Dapp: deploying
This fork is queued for its own live dapp on Sol.College, with a Devnet/Mainnet switch. It appears here, at /dapps/wallet-adapter/, once it is deployed and checked on devnet. Until then, run it locally with the commands below.
Key code, explained
Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.
packages/core/base/src/adapter.ts L97–119 @ 5f33bc6 · Apache-2.0 · original abstract sendTransaction( transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>, connection: Connection, options?: SendTransactionOptions ): Promise<TransactionSignature>; protected async prepareTransaction( transaction: Transaction, connection: Connection, options: SendOptions = {} ): Promise<Transaction> { const publicKey = this.publicKey; if (!publicKey) throw new WalletNotConnectedError(); transaction.feePayer = transaction.feePayer || publicKey; transaction.recentBlockhash = transaction.recentBlockhash || ( await connection.getLatestBlockhash({ commitment: options.preflightCommitment, minContextSlot: options.minContextSlot, }) ).blockhash;- Line 97
abstract sendTransaction(: Submits the signed transaction to the cluster. - Line 115
await connection.getLatestBlockhash({: Fetches a recent blockhash. Transactions expire if it gets too old.
packages/starter/example/src/components/SendTransaction.tsx L1–24 @ 5f33bc6 · Apache-2.0 · originalimport { Button } from '@mui/material';import { useConnection, useWallet } from '@solana/wallet-adapter-react';import type { TransactionSignature } from '@solana/web3.js';import { PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js';import React, { useCallback, type FC } from 'react';import { useNotify } from './useNotify'; export const SendTransaction: FC = () => { const { connection } = useConnection(); const { publicKey, sendTransaction } = useWallet(); const notify = useNotify(); const onClick = useCallback(async () => { let signature: TransactionSignature | undefined = undefined; try { if (!publicKey) throw new Error('Wallet not connected!'); const { context: { slot: minContextSlot }, value: { blockhash, lastValidBlockHeight }, } = await connection.getLatestBlockhashAndContext(); const transaction = new Transaction({ feePayer: publicKey,- Line 10
const { publicKey, sendTransaction } = useWallet();: Submits the signed transaction to the cluster. - Line 21
} = await connection.getLatestBlockhashAndContext();: Fetches a recent blockhash. Transactions expire if it gets too old.
packages/starter/example/src/components/SendLegacyTransaction.tsx L25–48 @ 5f33bc6 · Apache-2.0 · original } = await connection.getLatestBlockhashAndContext(); const message = new TransactionMessage({ payerKey: publicKey, recentBlockhash: blockhash, instructions: [ { data: Buffer.from('Hello, from the Solana Wallet Adapter example app!'), keys: [], programId: new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'), }, ], }); const transaction = new VersionedTransaction(message.compileToLegacyMessage()); signature = await sendTransaction(transaction, connection, { minContextSlot }); notify('info', 'Transaction sent:', signature); await connection.confirmTransaction({ blockhash, lastValidBlockHeight, signature }); notify('success', 'Transaction successful!', signature); } catch (error: any) { notify('error', `Transaction failed! ${error?.message}`, signature); } }, [publicKey, supportedTransactionVersions, connection, sendTransaction, notify]);- Line 25
} = await connection.getLatestBlockhashAndContext();: Fetches a recent blockhash. Transactions expire if it gets too old. - Line 40
signature = await sendTransaction(transaction, connection, { minContextSlot });: Submits the signed transaction to the cluster.
How to run, build and test
These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.
| Directory | Command | Runs |
|---|---|---|
. | npm run build | turbo run build --concurrency=100% |
. | npm run test | turbo run test --concurrency=100% |
. | npm run lint | turbo run lint --concurrency=100% |
. | npm run deploy | pnpm run deploy:docs && pnpm run deploy:example |
What you could build from it
- Fork the SuperStack copy and extend it within the Wallets & Identity gaps listed on the idea page.
- Learn the pattern first: Building and sending transactions from a client
- Learn the pattern first: Program Derived Addresses (PDAs)