Knowledge Base updated: 2026-11-15
Solana Web3.js knowledge base
Solana Web3.js is the JavaScript/TypeScript client library for constructing Solana transactions, communicating with RPC nodes, and integrating browser wallets.
The core library lives in src/; its Connection client manages HTTP JSON-RPC and WebSocket subscriptions, while transaction, message, key, account, and program modules model protocol data.
Workspace packages provide React wallet integration and a controllable test wallet. Transaction state is assembled in messages and transactions, signed by keypairs or wallets, serialized to bytes, then submitted and confirmed through Connection.
flowchart TD
App[Application] --> Conn[Connection]
Conn --> Rpc[HTTP JSON-RPC]
Conn --> Ws[WebSocket subscriptions]
App --> Ix[TransactionInstruction]
Ix --> Msg[Legacy / v0 Message]
Msg --> Tx[Transaction / VersionedTransaction]
Keys[PublicKey / Keypair] --> Tx
Tx --> Conn
Native[Native program builders] --> Ix
Alt[Address lookup tables] --> Msg
Rpc --> Cluster[Solana cluster]
Ws --> Cluster
Wallet[Wallet adapter React packages] --> Conn
Wallet --> Tx
TestWallet[Test wallet package] --> Wallet
Glossary
- Connection — the web3.js RPC client combining HTTP requests and WebSocket listener management.
- Commitment — the requested Solana confirmation level used by RPC reads and transaction confirmation.
- Versioned transaction — a transaction carrying a versioned message, including v0 address lookup table support.
- Address lookup table (ALT) — an on-chain account that supplies addresses compactly to v0 messages.
- Wallet adapter — the React-oriented package layer that presents wallet capability and connection state to applications.
Invariants
- Public keys and transaction message account ordering must remain canonical; see src/publickey.ts and
src/message/**. - Serialized transaction bytes must match the signatures and compiled message they contain; see
src/transaction/**and src/versioned-transaction.ts. - RPC listener IDs and client-side subscription state must be coordinated across reconnects; see src/connection.ts.
- Native program instruction data must use the program-specific binary layouts expected on chain; see
src/programs/**. - Wallet UI state must be driven through provider/controller state rather than independent connection state; see
packages/wallet-adapter-react/src/**.
Routing table
-
src/connection.ts, src/rpc-websocket.ts -> docs/connection-and-rpc.md
-
src/connection.ts, src/rpc-websocket.ts -> docs/websocket-subscriptions.md
-
src/…/to-legacy-rpc*.ts, src/…/from-legacy-rpc*.ts, src/…/kit*.ts -> docs/kit-adapters.md
-
src/transaction/**, src/transaction.ts, src/versioned-transaction.ts -> docs/transactions.md -
src/transaction.ts, src/versioned-transaction.ts, src/…/legacy.ts -> docs/legacy-and-versioned-transactions.md
-
src/…/send-and-confirm-*.ts, src/connection.ts, src/…/expiry-custom-errors.ts -> docs/transaction-send-and-confirm.md
-
src/message/**, src/message.ts -> docs/messages.md -
src/message/**, src/message-v0.ts, src/message-v1.ts -> docs/message-compilation-and-versions.md -
src/instruction.ts,
src/programs/**-> docs/programs-and-instructions.md -
src/…/system.ts, src/…/stake.ts, src/…/vote.ts, src/…/compute-budget.ts, src/…/ed25519.ts, src/…/secp256k1.ts, src/…/bpf-loader.ts -> docs/native-program-apis.md
-
src/…/address-lookup-table.ts,
src/address-lookup-table/**-> docs/address-lookup-table-program.md -
src/publickey.ts, src/keypair.ts, src/account.ts -> docs/accounts-and-identity.md
-
src/publickey.ts, src/keypair.ts, src/…/ed25519.ts -> docs/keys-and-signatures.md
-
src/nonce-account.ts, src/vote-account.ts, src/validator-info.ts, src/sysvar.ts, src/layout.ts -> docs/account-state-and-layouts.md
-
src/cluster.ts,
src/utils/**-> docs/network-and-protocol-utilities.md -
src/cluster.ts,
src/utils/**, src/timing.ts -> docs/cluster-and-encoding-helpers.md -
packages/wallet-adapter-react/**,packages/wallet-adapter-react-ui/**-> docs/wallet-adapter.md -
packages/wallet-adapter-react/src/**-> docs/wallet-provider-and-controller.md -
packages/wallet-adapter-react-ui/src/**-> docs/wallet-ui-components.md -
packages/test-wallet/**-> docs/test-wallet.md -
packages/test-wallet/src/**,packages/test-wallet/test/**-> docs/test-wallet-interactions-and-approvals.md