This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| @solana/web3.js (source) | ^1.98.4 → ^3.1.1 |
Release Notes
solana-foundation/solana-web3.js (@​solana/web3.js)
v3.1.1
v3.1.1
Full changelog: v3.1.0...v3.1.1
Published Packages
Installation
pnpm add @solana/web3.js@3.1.1 @solana/wallet-adapter@3.1.1v3.1.0
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.0What's Changed
- fix(web3.js): handle nullish memcmp in data-size filters by @snuff12 in #3977
- fix(web3.js): reject unsupported memcmp encodings in getProgramAccounts filters by @amilz in #3978
- docs(web3.js): note planned durable nonce deprecation on nonce APIs by @amilz in #3979
- chore(wallet-adapter): bump @solana/surfpool to ^1.6.1 by @amilz in #3981
- chore: bump next from 16.3.6 to 16.3.8 in the npm_and_yarn group across 1 directory by @dependabot[bot] in #3982
- feat(examples): add web3.js v3 basics node scripts by @amilz in #3980
- chore(web3.js): bump to @solana/kit 8.5 ^8.5.0 and support verifySignature change by @amilz in #3984
- ci: skip PR hygiene checks on closed pull requests by @amilz in #3988
- feat(web3.js): make Connection a Kit client (rpc, rpcSubscriptions, getMinimumBalance) by @amilz in #3983
- fix(web3.js): skip ws error log when the socket closes with no active subscriptions by @amilz in #3987
- feat(examples): add Anchor 2 example and use Connection as a Kit client by @amilz in #3985
- chore: bump version to v3.1.0 by @amilz in #3989
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
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.2What's Changed
- chore: bump wallet plugin and react by @amilz in #3971
- chore: adopt new contributing, issue, and PR policies by @amilz in #3973
- chore(deps): bump oxfmt to 0.72 to patch tinypool advisories by @amilz in #3972
- chore: bump version to v3.0.2 by @amilz in #3974
Full Changelog: https://github.com/solana-foundation/solana-web3.js/compare/v3.0.1...v3.0.2
v3.0.1
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.1What's Changed
- chore: update version by @amilz in #3965
- chore: bump kit to 8.4 and solana deps; pin stake to 0.9.0 by @amilz in #3968
- chore: release web3.js and wallet-adapter 3.0.1 by @amilz in #3969
Full Changelog: https://github.com/solana-foundation/solana-web3.js/compare/v3.0.0...v3.0.1
v3.0.0
These notes summarize the user-facing changes that landed since 1.98.4.
Highlights
Connectionnow runs on typed Solana Kit HTTP and websocket transports end-to-end, replacing the older JSON-RPC plumbing while preserving the class-basedweb3.jsAPI 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
bigintnumerics,Uint8Arrayaccount 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
PublicKeyconstructor inputs such asPublicKeyDataor{ _bn: BN }are no longer accepted. Keypair.generate(),Keypair.fromSecretKey(...), andKeypair.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.addressis now a Kit branded base58 address string for signer API compatibility. UseKeypair.publicKeywhen you need the web3.jsAddressclass 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
Web3Signershape ({publicKey, secretKey}) and theMessageSignertype alias were removed. The exportedSignertype is nowMessagePartialSigner & TransactionPartialSignerfrom@solana/kit, and transaction signing APIs accept any KitTransactionPartialSigner, whichSignersatisfies. PassKeypairinstances or other Kit transaction signers; migrate any remaining{publicKey, secretKey}literals viaawait Keypair.fromSecretKey(legacySigner.secretKey). - The implicit
Connectiondefault commitment changed fromfinalizedtoconfirmed. - Many migrated
Connectionmethods now return Kit-nativebigintvalues instead of legacynumbervalues. - Slot-like and
minContextSlotinputs were widened tonumber | bigintand now reject unsafe numeric inputs. AccountInfo-like responses now useUint8Arraypayloads, readonly wrappers, andspace: bigintinstead of the old mutableBuffer-centric shapes.- The deprecated FeeCalculator surface was removed, including
FeeCalculator,getRecentBlockhash,getRecentBlockhashAndContext, andgetFeeCalculatorForBlockhash. - The legacy
Accountclass 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 resolving0n. 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 withinstanceof Transactionandinstanceof TransactionInstructioninstead of the previous'instructions' in item/'data' in itemduck-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.fetchandfetchMiddlewareremain 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'sfee,preBalances,postBalances,preTokenBalances,postTokenBalances, andloadedAddresseson the simulation result when the RPC returns them, matching Kit's simulation response.- Repeated
getBlockHeightcalls with equivalent arguments are now coalesced. getSignatureStatusesandgetSignatureStatusaccept optionalcommitmentandminContextSlot, andsearchTransactionHistoryis now optional.getTransaction,getParsedTransaction, and their batch variants acceptminContextSlot. Nodes running Agave without anza-xyz/agave#15091 ignore the new fields.getLeaderScheduleacceptskeyByVoteAccountto 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
PublicKeyremains the primary address type; theAddressclass shipped in earlier 3.0.0 release candidates has been removed.PublicKey.toBase58()returns the kit-brandedAddressstring.Keypairimplements Kit'sKeyPairSignerinterface. It exposesaddress,keyPair,signMessages(...), andsignTransactions(...), and can be passed directly to Kit APIs and generated program clients that accept aTransactionSignerorKeyPairSigner.Keypair.addressis Kit's brandedAddressstring (base58).Keypair.publicKeyremains the web3.jsPublicKeyobject for class-based address operations.- The exported
Signertype is nowMessagePartialSigner & TransactionPartialSignerfrom@solana/kit. The legacy{publicKey, secretKey}shape is no longer accepted byTransaction.sign(...),Transaction.partialSign(...),VersionedTransaction.sign(...),Connection.sendTransaction(...),Connection.simulateTransaction(...), orsendAndConfirmTransaction(...). All of these accept any KitTransactionPartialSigner(Signer, whatKeypairprovides, satisfies it) and assert transaction-signing capability at runtime;Transaction.sign(...),Transaction.partialSign(...), andVersionedTransaction.sign(...)sign through Kit'spartiallySignTransactionWithSigners, 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 (MessagePartialSignerwithoutsignTransactions) are rejected. PassKeypairinstances or any other KitTransactionPartialSigner. Transaction.sign(...),Transaction.partialSign(...),VersionedTransaction.sign(...),Connection.sendTransaction(...),Connection.simulateTransaction(...), andsendAndConfirmTransaction(...)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 whenevernonceInfois set, even if the transaction still carriesrecentBlockhashandlastValidBlockHeight. Previously, stale blockheight fields left on a reusedTransactioncould produce a falseTransactionExpiredBlockheightExceededErrorafter 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, andArray<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.decodeSplitanddecodeWithdrawnow returnlamports: bigint(typed asDecodedSplitStakeInstruction/DecodedWithdrawStakeInstruction) instead of narrowing exact u64 amounts tonumber. Stake builder params (createAccount,createAccountWithSeed,split,splitWithSeed,withdraw) acceptlamports: 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, andAddressLookupTableAccount.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 generatedlib/output included. - The old
node-fetchfallback 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 producebigint. - If you serialize SDK responses or mocks with
JSON.stringify, remember that rawbigintvalues throw without a replacer. - Prefer propagating
bigintthrough app state and only converting withNumber(...)at display or interoperability boundaries, with safe-range checks where precision matters. - When interoperating with
@solana/kitor generated program clients, convert withpublicKey.toBase58()(web3.js → kit) andnew PublicKey(kitAddress)(kit → web3.js)..toBase58()returns Kit's brandedAddressstring, which is assignable anywhere a plainstringis expected. - Replace
keypair.address.toBytes(),keypair.address.equals(...), andkeypair.address.toBase58()withkeypair.publicKey.toBytes(),keypair.publicKey.equals(...), andkeypair.publicKey.toBase58(). If you only need the base58 signer address, usekeypair.addressdirectly. - 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 aKeypair(e.g.await Keypair.fromSecretKey(legacySigner.secretKey)) or another Kit signer. TheWeb3Signerinterface and theMessageSigneralias 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 keepingBufferas your internal default.
v2.0.0
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
@solana/web3.js v1.99.0
Add v1 Transaction read support #3866
Installation
pnpm add @solana/web3.js@1.99.0Configuration
📅 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.