At the recent Breakpoint 2023 event organized by Solana, Steven Luscher—a JavaScript Engineer at Solana Labs—provided insights on the latest iteration of Solana Web3.js. He emphasized its implications for developers constructing decentralized applications (dapps) on the Solana blockchain.
Web3.js serves as a comprehensive toolkit empowering developers to establish connections with blockchains via various communication methods, such as HTTP, IPC, or WebSocket.
Normally, each blockchain possesses its own customized version or library, similar to Web3.js, which caters to its distinctive functionalities and protocols.
For example, Ethereum has Web3.js for interacting with its blockchain, while Solana has Solana-Web3.js designed specifically for Solana.
These libraries provide developers with the tools and functions needed to interact with the respective blockchain, such as sending transactions, querying data, and managing smart contracts. The specific library used depends on the blockchain platform a developer is working with.
When compared to traditional APIs, Steven said that the new Solana Web3.js API is a better choice. It equips developers with more effective tools for creating applications in the industry.
In simpler terms, it’s like giving developers a better set of tools to build cool things on the Solana blockchain.
The decision to update the software was driven by user feedback. Developers expressed their desire for improved customization, less opinionated features, and the ability to meet diverse application requirements. Mango Protocol provided several examples to support these needs.
Updates features
The engineer said that one significant improvement is making the new Web3.js API tree-shakable. “You told me, Steve, I’m happy that you offer all of these 110 billion methods for me to call but I only use three or five,” he said to the audience. “But when I include web3.js in my project, I get all of them whether I like it or not.”
So in response to this complaint, Steven explained that the compilers have been optimized to allow developers to choose the method they want to use without the need for extra tools that have been integrated into the Web3 Js tool.
Additionally, the update addresses compatibility with modern JavaScript features, such as BigInt and native support for the ed25519 encryption algorithm. Ed25519 is a public-key signature system that is supported by many SSH clients.
It is a secure public-key signature system that is used in various protocols and software and has been implemented on AWS although it’s flagged off on a platform such as Chrome.
He went on to say that the reduction in bundle size for the new Web3.js is substantial, significantly outperforming its predecessor.
In a real-world example, the Solana Explorer experienced a 26% size reduction on the homepage after migrating to the new Web3.js, demonstrating the practical impact of these improvements.
Other changes integrated
The engineer added that the new RPC (Remote Procedure Call) API has been revamped to be more concise, with a focus on simplicity and cancelability while the new RPC transport is customizable, allowing developers to implement strategies like fallback mechanisms for handling different RPC endpoints.
A notable addition is the Subscriptions API, now based on modern JavaScript async iterators. This not only introduces cancellability but also enables “Gap Recovery,” allowing developers to seamlessly recover from missed data during a subscription interruption.
Key management in the new Web3.js leverages native JS crypto keys, offering improved performance and leak resistance. The presentation highlighted the advantages of this approach, emphasizing the protection of private key content even in the event of unintentional logging.
Transaction builders have been unified, simplifying the process of constructing transactions with functional transforms. TypeScript integration plays a crucial role in providing developers with early detection of common errors, ensuring a smoother development process.
The future
Looking ahead, he said that the Web3.js team is actively working on code generation tools for programs, promising an API that aligns more closely with developers’ objectives and desires.
This initiative aims to deliver tailored solutions for various programs, extending the benefits of Web3.js to a broader spectrum of applications.
Developers were encouraged to explore the technology preview, provide feedback, and participate in the migration process. Steven shared his willingness to offer one-on-one assistance to those undertaking the migration, emphasizing a collaborative approach to refining the Web3.js library.