New Starknet Wallet<>Dapp API

TL;DR

After a long and fruitful community effort, the Starknet JS stack is being updated with a new Wallet<>Dapp API.
The new API simplifies Wallet<>Dapp communication and decouples the dependencies between wallets, dapps and starknet.js versions.
There is a new starknet.js release with support for the new API, new starknet-react and get-starknet versions, and a new home for Starknet npm packages.
The following post summarizes the main changes, how this affects the ecosystem, and what you should do to prepare for the changes.

The current state of Starknet.js and wallet integration

Until now, for a Dapp to connect to a Starknet wallet, it received an Account object injected into the window by the wallets and interacted with the wallet with all the methods supported by the Account class in starknet.js. This meant, in part, that if a new version of Starknet.js was released, both wallets and Dapps were required to upgrade to the new version to stay compatible with the latest Starknet API and Starknet.js features.

This coupling stifled progress and required redundant coordination overhead to move the ecosystem forward.

New Starknet.js stack

Starting with the Starknet community forum discussion, Argent proposed decoupling wallets from Starknet.js by facilitating a message-based API between wallets and Dapps.

Moving to an API-based communication means wallets and Dapps no longer need to support specific Starknet.js versions as long as they communicate with the same API.

After many discussions and reviews of the new API PR, the new official wallet<>Dapp API has been added to the Starknet-specs repository.

What is the new API all about?

Instead of directly invoking Account methods, a PRC message is sent to the wallet. The API supports only methods that require the wallet.

These methods provide, in part, the functionality to :

  • Get account address information
  • Send Invoke and Declare transactions
  • Sign SNIP-12 typed data
  • etc.

Notably, the new API does not allow to send requests to the wallet that can be solely handled by a Starknet Provider. It is up to the Dapp to use either their own node or one of Starknet’s RPC providers to get information about the blockchain.

The new API creates a clear separation of concerns between the Dapp, the wallet and the provider. For example, the API does not externalize any options for fee or transaction type selection, which are handled by the wallet. The Dapp should only be concerned with building the appropriate calls and sending them to the wallet for signing and broadcasting.

Along with the new API, a new stack of repositories is released to make transitioning to the new API as seamless as possible.

New repositories and packages

types-js

One of the benefits of a unified API is that we can now have a types package, standardizing the expected JS types on both ends. The new types-js repository can be found under

The types repository will follow the versioning of the main Starknet PRC, with only differences to the patch number. The current version is 0.7.X

Starknet.js

Starknet.js version 6 and up will support the new API via a new class, WalletAccount. The class is initiated with a Starknet Provider and a Starknet Wallet, which are provided by the wallet extensions. From that point on, interactions with the account are very similar to the current Account in Starknet.js. All of the communication with the wallet is implemented under the hood.

You can read more about WalletAccount in the starknet.js documentation.
Version 5, which supports the old API, will still be available if you specify an exact version.

  • npm: npm install starknet

get-starknet

Get Starknet will be released under a new home on npm, under the @starknet-io organization. The new get-starknet V4 version is available for installation with npm install @starknet-io/get-starknet . The older V3 versions, currently available via npm install get-starknet, will remain available until the old API is End Of Life.

starknet-react

Starknet-react V3 will be released with support for the new types-js and the new API. Documentation on Starknet-react V3 is available here.

  • npm: npm add @starknet-react/chains@next @starknet-react/core@next

When will the API become the standard?

Starknet mainnet is planned to be updated to version 0.13.3 around September 2024. The new Starknet version will ship with and updated RPC version (0.8), and will drop support for old RPC versions older than RPC 0.7.

Starknet.js versions supporting the old RPC, and the old wallet<>Dapp API will then also be deprecated.

What should you do?

The upcoming months will be a transition period when both API versions will be supported by both Argent and Braavos, with additional wallets onboarding using the new API. So, how does this affect you?

New wallets coming to Starknet

  • See the links below for information about the new API spec and example Dapps working with the new API
  • Implement the new wallet<>Dapp communication API
  • Submit a PR to get-starknet to add your wallet to get-starknet discovery

Dapp developers

You are welcome to try out the new stack with the new versions of Starknet-js, starknet-react, and get-starknet. Arget and Braavos are already supporting the new API. While there will be a transition period when some of the other wallets add support for the new API, all existing and new wallets are expected to transition to it by the time of the next Starknet network upgrade (0.13.3).

Users

The change in API shouldn’t affect you. Both old and new API versions will continue to be available for a while. If you experience any issues with the support of your wallet in a Dapp, you are welcome to contact the Dapp developer or wallet provider.

Thanks

This important upgrade is a joint work of many parties. Special thanks to Janek from Argent for the initial SNIP proposal. To Abraham from Braavos for providing the initial implementation of the SNIP and the accompanying Braavos wallet. To Dhruv and Vladut from Argent. To Francesco from Apibara for adding support to starknet-react, to Toni Tabak and the team at SpaceShard for the incredible work on Starknet-js and types.js and for adding support to the new API. To Naor and Dan Ziv form StarkWare for adding the new API to get-starknet. To Philippe Rostan from critical.devs.fr for the help testing, reviewing, commenting, and building the demo Dapps for the new API.

Useful links

its awesome to see the new API standard on Starknet soon

The introduction of the new API, decoupling wallets from specific Starknet.js versions, seems like a significant improvement for the ecosystem. However, it raises the question of how this change will impact the speed and ease of development for new entrants to the Starknet ecosystem. Will this simplify the process for beginner developers, or could it potentially introduce new challenges at the outset?

The article does an excellent job of explaining the complex technical changes, providing a clear overview and practical recommendations for the different user groups in the Starknet ecosystem.
How will Starknet’s new API improve user experience with wallets and apps?