ReviewOS

also looking at this

stacks/ts-tokens

chore(deps): update dependency @solana/web3.js to v3

#2085
Open renovate[bot] wants to merge renovate/solana-web3.js-3.x into main
5 files +317 -211
8 days ago

This PR contains the following updates:

PackageChangeAgeAdoptionPassingConfidence
@solana/web3.js (source)^1.98.4 → ^3.1.1ageadoptionpassingconfidence

Release Notes

solana-foundation/solana-web3.js (@​solana/web3.js)

v3.1.1

Compare Source

v3.1.1

V3 Migration Details

Full changelog: v3.1.0...v3.1.1

Published Packages
Installation
pnpm add @solana/web3.js@3.1.1 @solana/wallet-adapter@3.1.1

v3.1.0

Compare Source

v3.1.0

Full changelog: v3.0.2...v3.1.0

Published Packages
Installation
pnpm add @solana/web3.js@3.1.0 @solana/wallet-adapter@3.1.0
What's Changed
Connection now implements a Kit client

That means you can pass it straight to Kit-native libraries like Anchor 2 and the Codama-generated @solana-program/* clients, without building a second RPC.

Anchor 2: give a Connection and Keypair to AnchorProvider:

import {AnchorProvider, Program} from '@anchor-lang/core';
import {Connection, Keypair, sendAndConfirmTransaction, Transaction} from '@solana/web3.js';

const connection = new Connection(rpcUrl, 'confirmed');
const provider = new AnchorProvider(connection, trader);
const program = new Program<Whirlpool>(idl, provider);

const {data: pool} = await program.account.whirlpool.fetch(SOL_USDC_POOL);

const swapIx = await program.methods
  .swap(USDC_IN, 0n, MAX_SQRT_PRICE, true, false)
  .accounts({whirlpool: SOL_USDC_POOL, tokenVaultA: pool.tokenVaultA, /* ... */})
  .instruction();

await sendAndConfirmTransaction(connection, new Transaction().add(swapIx), [trader]);

Solana program clients: pass the Connection to helpers that need rent. You don't need to call getMinimumBalanceForRentExemption or build createAccount yourself:

import {getCreateMintInstructionPlan} from '@solana-program/token';
import {Connection, Keypair, sendAndConfirmTransaction, Transaction} from '@solana/web3.js';

const connection = new Connection(rpcUrl, 'confirmed');
const mint = await Keypair.generate();

const createMint = await getCreateMintInstructionPlan(connection, {
  decimals: 6,
  mintAuthority: payer.publicKey,
  newMint: mint,
  payer,
});

await sendAndConfirmTransaction(connection, new Transaction().add(createMint), [payer, mint]);

Full examples: examples/ecosystem/anchor and examples/basics

New Contributors

Full Changelog: https://github.com/solana-foundation/solana-web3.js/compare/v3.0.2...v3.1.0

v3.0.2

Compare Source

v3.0.2

Full changelog: v3.0.1...v3.0.2

Published Packages
Installation
pnpm add @solana/web3.js@3.0.2 @solana/wallet-adapter@3.0.2

What's Changed

Full Changelog: https://github.com/solana-foundation/solana-web3.js/compare/v3.0.1...v3.0.2

v3.0.1

Compare Source

v3.0.1

Full changelog: v3.0.0-rc.3...v3.0.1

Published Packages
Installation
pnpm add @solana/web3.js@3.0.1 @solana/wallet-adapter@3.0.1

What's Changed

Full Changelog: https://github.com/solana-foundation/solana-web3.js/compare/v3.0.0...v3.0.1

v3.0.0

Compare Source

These notes summarize the user-facing changes that landed since 1.98.4.

Highlights

  • Connection now runs on typed Solana Kit HTTP and websocket transports end-to-end, replacing the older JSON-RPC plumbing while preserving the class-based web3.js API shape.
  • Websocket subscription setup failures no longer spin through indefinite retry loops; failed opens now become terminal until listener demand changes or the transport reconnects.
  • The library has moved much further toward Uint8Array-first and async-first behavior, reducing Buffer-specific behavior and aligning signing and verification with WebCrypto/Kit.
  • Program and account encode/decode paths have been modernized around codecs and vendored generated program clients.
  • Packaging, build, and install flows were refreshed, including esbuild-based bundling, generated lib/ output for git installs, and updated validator/dependency tooling.

Migration Reality Check

  • The public API is still class-based, but non-trivial TypeScript consumers should still expect broad mechanical migration work. In practice, the largest sources of churn are bigint numerics, Uint8Array account data, async key/serialization helpers, and readonly RPC results, and more specific SDK types for values such as addresses, blockhashes, slots, lamports, and timestamps.
  • For full-app consumers already using most of the class surface, the immediate payoff is usually API modernization and future compatibility rather than a dramatic bundle-size reduction.

Breaking Changes

  • PublicKey.unique() was removed.
  • Legacy BN-era PublicKey constructor inputs such as PublicKeyData or { _bn: BN } are no longer accepted.
  • Keypair.generate(), Keypair.fromSecretKey(...), and Keypair.fromSeed(...) are now async. Tests and stories that previously used sync key generation often need to become async or switch to app-local dummy public-key helpers.
  • Keypair.address is now a Kit branded base58 address string for signer API compatibility. Use Keypair.publicKey when you need the web3.js Address class methods such as .toBytes(), .equals(...), or .toBase58().
  • Transaction.verifySignatures() is now async and returns a promise.
  • Transaction.serialize() is now async and must be awaited.
  • Remaining sync signing helpers that existed earlier in the range were removed in favor of the async signing surface.
  • The legacy Web3Signer shape ({publicKey, secretKey}) and the MessageSigner type alias were removed. The exported Signer type is now MessagePartialSigner & TransactionPartialSigner from @solana/kit, and transaction signing APIs accept any Kit TransactionPartialSigner, which Signer satisfies. Pass Keypair instances or other Kit transaction signers; migrate any remaining {publicKey, secretKey} literals via await Keypair.fromSecretKey(legacySigner.secretKey).
  • The implicit Connection default commitment changed from finalized to confirmed.
  • Many migrated Connection methods now return Kit-native bigint values instead of legacy number values.
  • Slot-like and minContextSlot inputs were widened to number | bigint and now reject unsafe numeric inputs.
  • AccountInfo-like responses now use Uint8Array payloads, readonly wrappers, and space: bigint instead of the old mutable Buffer-centric shapes.
  • The deprecated FeeCalculator surface was removed, including FeeCalculator, getRecentBlockhash, getRecentBlockhashAndContext, and getFeeCalculatorForBlockhash.
  • The legacy Account class was removed.
  • Deprecated BufferLayout-based internals and compatibility surfaces were removed in favor of codec-backed implementations.
  • Connection.getMinimumBalanceForRentExemption(...) now propagates RPC and transport failures instead of logging a warning and resolving 0n. Callers that relied on the zero fallback must handle the rejection, because a failed rent query should not be mistaken for a rent-free account.
  • Transaction.add(...) now narrows its inputs with instanceof Transaction and instanceof TransactionInstruction instead of the previous 'instructions' in item / 'data' in item duck-typing checks. Loose "Transaction-like" or "TransactionInstruction-like" objects that aren't real instances will no longer be accepted at runtime. Well-typed TypeScript callers are unaffected.

API And Runtime Changes

Connection
  • HTTP requests now go through typed Kit RPC calls instead of the legacy request pipeline.
  • Websocket subscriptions now run on a Kit-backed subscription runtime with stronger request/response shaping and broader payload coverage.
  • Websocket subscriptions now match Kit's default 100-subscription channel limit for improved stability.
  • Added Connection.awaitSubscriptionReady(...) so callers can await websocket subscription establishment, explicit setup failure, or listener invalidation.
  • Shared websocket subscriptions now invalidate readiness per client listener, so removing one deduplicated listener before acknowledgement no longer resolves readiness for the wrong listener.
  • Signature-confirmation fallback now treats failed or inactive subscription setup as terminal and continues via getSignatureStatuses() when needed.
  • ConnectionConfig.fetch and fetchMiddleware remain available as compatibility hooks on top of the typed HTTP path.
  • Additional RPC coverage and stricter typing landed across account, block, transaction, token, simulation, and node metadata methods.
  • Connection.simulateTransaction(...) now surfaces the RPC's fee, preBalances, postBalances, preTokenBalances, postTokenBalances, and loadedAddresses on the simulation result when the RPC returns them, matching Kit's simulation response.
  • Repeated getBlockHeight calls with equivalent arguments are now coalesced.
  • getSignatureStatuses and getSignatureStatus accept optional commitment and minContextSlot, and searchTransactionHistory is now optional. getTransaction, getParsedTransaction, and their batch variants accept minContextSlot. Nodes running Agave without anza-xyz/agave#15091 ignore the new fields.
  • getLeaderSchedule accepts keyByVoteAccount to key the returned schedule by vote account instead of validator identity. Nodes running Agave without anza-xyz/agave#13796 ignore the field.
  • Many RPC arrays and nested collections are now readonly, so code that mutates in place may need to spread or clone first.
Addresses, transactions, and signing
  • PublicKey remains the primary address type; the Address class shipped in earlier 3.0.0 release candidates has been removed. PublicKey.toBase58() returns the kit-branded Address string.
  • Keypair implements Kit's KeyPairSigner interface. It exposes address, keyPair, signMessages(...), and signTransactions(...), and can be passed directly to Kit APIs and generated program clients that accept a TransactionSigner or KeyPairSigner.
  • Keypair.address is Kit's branded Address string (base58). Keypair.publicKey remains the web3.js PublicKey object for class-based address operations.
  • The exported Signer type is now MessagePartialSigner & TransactionPartialSigner from @solana/kit. The legacy {publicKey, secretKey} shape is no longer accepted by Transaction.sign(...), Transaction.partialSign(...), VersionedTransaction.sign(...), Connection.sendTransaction(...), Connection.simulateTransaction(...), or sendAndConfirmTransaction(...). All of these accept any Kit TransactionPartialSigner (Signer, what Keypair provides, satisfies it) and assert transaction-signing capability at runtime; Transaction.sign(...), Transaction.partialSign(...), and VersionedTransaction.sign(...) sign through Kit's partiallySignTransactionWithSigners, deriving the blockhash or durable nonce lifetime from the compiled message; VersionedTransaction.sign(signers, {lastValidBlockHeight}) forwards the block height to signers that need it. Message-only signers (MessagePartialSigner without signTransactions) are rejected. Pass Keypair instances or any other Kit TransactionPartialSigner.
  • Transaction.sign(...), Transaction.partialSign(...), VersionedTransaction.sign(...), Connection.sendTransaction(...), Connection.simulateTransaction(...), and sendAndConfirmTransaction(...) can now sign with compatible Kit signer objects.
  • Verification is now WebCrypto/Kit-backed and async-only.
  • sendAndConfirmTransaction(...) now confirms with the durable-nonce strategy whenever nonceInfo is set, even if the transaction still carries recentBlockhash and lastValidBlockHeight. Previously, stale blockheight fields left on a reused Transaction could produce a false TransactionExpiredBlockheightExceededError after the nonce-backed transaction had already landed.
  • Transaction and message internals were normalized around Uint8Array, including instruction data, signatures, serialization, and deserialization.
  • Buffer-backed public APIs now accept Uint8Array, sliced views, and Array<number> more consistently.
Programs and decoders
  • Address Lookup Table, Compute Budget, System, Stake, Vote, ValidatorInfo, and VoteAccount code paths were migrated to codec-backed or generated-client-backed implementations.
  • Vote account decoding now covers newer state variants and prior-voter normalization.
  • Stake account decoding coverage now includes initialized, delegated, and non-data variants.
  • StakeInstruction.decodeSplit and decodeWithdraw now return lamports: bigint (typed as DecodedSplitStakeInstruction / DecodedWithdrawStakeInstruction) instead of narrowing exact u64 amounts to number. Stake builder params (createAccount, createAccountWithSeed, split, splitWithSeed, withdraw) accept lamports: number | bigint.
  • Vendored generated program clients now back address-lookup-table, compute-budget, stake, and system support.
  • Connection.getAddressLookupTable(...) now throws when the fetched account is not owned by the Address Lookup Table program, and AddressLookupTableAccount.deserialize(...) rejects data whose discriminator is not the initialized lookup table variant, instead of decoding arbitrary account bytes as a lookup table.

Tooling And Packaging

  • The build moved from Babel to esbuild.
  • Git installs now work through prepack, with generated lib/ output included.
  • The old node-fetch fallback path and fetch fork files were removed.
  • bs58, BufferLayout, Buffer-centric helpers, and other dead utilities were removed as the runtime moved to codecs and typed arrays.
  • ESLint moved to flat config, dependencies were refreshed, and the test-validator flow was updated to Agave v3.

Upgrade Notes

  • Audit all transaction serialization and signature-verification call sites for missing await.
  • Audit any code that assumes slots, counts, context values, lamports-like fields, or timestamps are number; migrated Connection methods may now produce bigint.
  • If you serialize SDK responses or mocks with JSON.stringify, remember that raw bigint values throw without a replacer.
  • Prefer propagating bigint through app state and only converting with Number(...) at display or interoperability boundaries, with safe-range checks where precision matters.
  • When interoperating with @solana/kit or generated program clients, convert with publicKey.toBase58() (web3.js → kit) and new PublicKey(kitAddress) (kit → web3.js). .toBase58() returns Kit's branded Address string, which is assignable anywhere a plain string is expected.
  • Replace keypair.address.toBytes(), keypair.address.equals(...), and keypair.address.toBase58() with keypair.publicKey.toBytes(), keypair.publicKey.equals(...), and keypair.publicKey.toBase58(). If you only need the base58 signer address, use keypair.address directly.
  • Prefer passing Kit-compatible signers directly to transaction signing APIs instead of wrapping them in noop signers solely to satisfy web3.js types.
  • Replace any remaining {publicKey, secretKey} signer literals with a Keypair (e.g. await Keypair.fromSecretKey(legacySigner.secretKey)) or another Kit signer. The Web3Signer interface and the MessageSigner alias are no longer exported.
  • Replace any dependency on removed helper APIs such as PublicKey.unique(), FeeCalculator-related methods, or BN-era key construction.
  • If you depend on Buffer-based decoders, convert at that boundary with Buffer.from(...) or a zero-copy aliasing form for hot paths instead of keeping Buffer as your internal default.

v2.0.0

Compare Source

Today we have dropped the Release Candidate label from @solana/web3.js v2.0.0. We now recommend it for general use.

Read more in this blog post.

v1.99.0: @​solana/web3.js v1.99.0

Compare Source

@​solana/web3.js v1.99.0

Add v1 Transaction read support #​3866

Installation
pnpm add @solana/web3.js@1.99.0

https://www.npmjs.com/package/@solana/web3.js/v/1.99.0


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

5 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.