npm @solana/web3.js 2.0.0-rc.2
The New web3.js - Release Candidate `rc.2`

latest releases: 2.0.0-canary-20241031190501, 2.0.0-canary-20241031172938, 2.0.0-canary-20241031172321...
13 hours ago

v2.0.0-rc.2 (2024-10-31)

We expect this to be the final release candidate version before tagging version 2.0 of @solana/web3.js. Please submit any final bug reports before Thursday, November 7th by filing a GitHub Issue.

To install the Release Candidate:

npm install --save @solana/web3.js@rc
  • Try the runnable examples in the examples/ directory to get a feel for the API.
  • Use the example dApp at https://solana-labs.github.io/solana-web3.js/example/ – source available here – for an example of how to build transactions with the new web3.js for use with wallets.
  • Install TypeScript clients for on-chain programs like System and Token, then build a useful application or backend service.

Changelog since Release Candidate rc.1

  • #3213 3fc388f Thanks @mcintyre94! - Clean up SolanaRpcApi: no longer extend RpcApiMethods + remove export

  • #3137 fd72c2e Thanks @mcintyre94! - The build is now compatible with the Vercel Edge runtime and Cloudflare Workers through the addition of edge-light and workerd to the package exports.

  • #3251 Thanks @ryoid! - isAddress() no longer throws despite that the input might be unparseable as a base-58 string. Now, it correctly, simply, returns false.

  • #3361 441fa3a Thanks @steveluscher! - Fixed a bug where calls to isEd25519CurveSupported() might have resulted in uncaught rejections bubbling up through the app, in cases where Ed25519 is not supported

  • #3134 38faba0 Thanks @buffalojoec! - Change unix timestamp type to bigint with an unsafe label

  • #3128 0158b31 Thanks @lorisleiva! - Fix missing export in @solana/keys package. This means, the getPublicKeyFromPrivateKey function is now properly exported.

  • #3407 10b08ac Thanks @lorisleiva! - Use RpcRequest, RpcResponse and their transformers in RPC Subscriptions packages

    This change makes the RPC and RPC Subscriptions architecture more consistent by using the same RpcRequest and RpcResponse types and transformers as the basis for handling user requests (RPC calls or subscriptions) and returning responses to them.

    See the following PRs for more details:

  • #3453 bafefed Thanks @mcintyre94! - Rename decodeTransactionMessage to decompileTransactionMessageFetchingLookupTables

  • #3290 2368163 Thanks @mcintyre94! - Throw an error if a transaction fails when being simulated to estimate CUs

  • #3145 1c25dd4 Thanks @lorisleiva! - Rename RpcResponse type to RpcResponseData to make room for a new RpcResponse type

  • #3213 3fc388f Thanks @mcintyre94! - Clean up SolanaRpcApi: no longer extend RpcApiMethods + remove export

  • #3454 1fde4b1 Thanks @mcintyre94! - Correct type of replacementBlockhash in simulateTransaction

  • #3456 0245265 Thanks @lorisleiva! - Remove UnsafeBeyond2Pow53Minus1 type suffixes

  • #3150 a705413 Thanks @lorisleiva! - Make RpcApi use new RpcRequestTransformer and RpcResponseTransformer

  • #3202 bf07a60 Thanks @disco-infinex! - PerformanceSample return type field numNonVoteTransaction corrected to numNonVoteTransactions

  • #3161 9dfca45 Thanks @lorisleiva! - Add getIntegerOverflowRequestTransformer, getBigIntDowncastRequestTransformer and getTreeWalkerRequestTransformer helpers

  • #3134 38faba0 Thanks @buffalojoec! - Change unix timestamp type to bigint with an unsafe label

  • #3148 e1cb697 Thanks @lorisleiva! - Make RpcTransport return new RpcReponse type instead of parsed JSON data

  • #3201 02cefa7 Thanks @lorisleiva! - Update the response type of the getClusterNodes RPC method

  • #3098 2f541b6 Thanks @buffalojoec! - Update program accounts filters for programAccounts query

  • #3221 6b43588 Thanks @lorisleiva! - Add new isJsonRpcPayload helper method

  • c8e6e71 Thanks @steveluscher! - We refactored the lower levels of the subscriptions API entirely.

    Previously, all layers of the subscriptions implementation, from the WebSocket transport to the API that developers use, dealt in AsyncIterables. These are notoriously difficult to code in such a way that expresses all of the ways in which a subscription might be cancelled or error out. Very slight omissions of care could open memory leaks that would bring down the simplest of apps. The new subscriptions infra in Release Candidate 2 deals with event-based subscriptions all the way up to the highest level API, at which point the subscription is vended to the application as an AsyncIterable.

    This has eliminated several classes of memory leak and has made it easier to implement higher-level transports (like the autopinger and the subscription coalescer). Additionally, this update introduces a new channel pool implementation that opens new WebSocket connections when existing ones become ‘full.’ Lastly, performance in the new implementation has been improved through a new demultiplexing utility that can separate message events into several channels based on arbitrary criteria, meaning you can apply transforms to the message right at the source, and vend subscriptions to downstream consumers that care only about one particular kind of message.

  • #3449 17c373d Thanks @lorisleiva! - Add transformChannelInboundMessages and transformChannelOutboundMessages helper functions to transform incoming and outgoing messages on a given channel.

  • #3433 92655fd Thanks @lorisleiva! - Rename executeSubscriptionPlan to execute in RpcSubscriptionsPlan

  • #3455 500a991 Thanks @lorisleiva! - Adds a channel creator function called createDefaultSolanaRpcSubscriptionsChannelCreator. This function works similarly to createDefaultRpcSubscriptionsChannelCreator but with some Solana-specific defaults. For instance, it safely handles BigInt values in JSON messages since Solana RPC servers accept and return integers larger than Number.MAX_SAFE_INTEGER.

  • #3451 8f94a9e Thanks @lorisleiva! - Add a `getRpcSubscriptionsChannelWithBigIntJSONSerialization` helper function that parses and stringifies JSON messages with support for `BigInt` values. Any integer value is parsed as a `BigInt` in order to safely handle numbers that exceed the JavaScript `Number.MAX_SAFE_INTEGER` value.

  • #3406 4c7224d Thanks @lorisleiva! - Replace subscriptionConfigurationHash with RpcRequest in RpcSubscriptionPlan

  • #3163 29d5113 Thanks @lorisleiva! - Add getThrowSolanaErrorResponseTransformer, getResultResponseTransformer, getBigIntUpcastResponseTransformer and getTreeWalkerResponseTransformer helpers

  • #3159 747b9ab Thanks @lorisleiva! - Add getDefaultCommitmentRequestTransformer helper

  • #3184 28ca5d1 Thanks @lorisleiva! - Remove temporary fix for Agave issue 479

    The fix is now deployed on mainnet-beta (See anza-xyz/agave#479 and anza-xyz/agave#483).

  • #3196 512853e Thanks @lorisleiva! - Add new createHttpTransportForSolanaRpc function that creates a new HTTP transport specific to the Solana RPC API. This transport uses custom JSON parsing and stringifying strategies on both the request and response of Solana RPC API requests in order to prevents loss of precision for large integers.

  • #3192 422f928 Thanks @lorisleiva! - Add fromJson and toJson options to the HTTP transport

  • #3467 3834d82 Thanks @lorisleiva! - Remove U64 and I64 types in favour of bigint

  • #3456 0245265 Thanks @lorisleiva! - Remove UnsafeBeyond2Pow53Minus1 type suffixes

  • #3340 44c8772 Thanks @steveluscher! - Enabled Brotli, gzip, and Deflate compression by default when running in Node.js, where compression headers are not added by the runtime like they are in browsers

  • #3481 4decebb Thanks @lorisleiva! - Remove the feePayerSigner attribute of transaction messages in favour of the existing feePayer attribute. This ensures fee payers are defined in a single place — whether they are using signers or not.

  • #3482 d4965ec Thanks @lorisleiva! - Override feePayer signer when the address matches the existing one. This is because users may want to provide a different wallet from the same address.

  • #3301 8c2cb9f Thanks @steveluscher! - Creates a package for working with subscribable data sources like event targets. From an EventTarget or object which conforms to the EventEmitter interface you can now create a more ergonomic DataPublisher (object with an on method that vends an unsubscribe function) or an abortable AsyncIterable.

  • #3353 696c72c Thanks @steveluscher! - Fixed a bug that could result in the transaction confirmer claiming that the blockheight had been exceeded, when the fact of the matter was that the confirmation was aborted by an AbortSignal

  • #3480 231a030 Thanks @lorisleiva! - Change feePayer type of transaction messages from Address to { address: Address }

Don't miss a new web3.js release

NewReleases is sending notifications on new releases.