Stellar Wallets Kit: A kit to handle all Stellar Wallets at once with a simple API
Last updated
Last updated
Stellar is known for its fast, low-cost, and scalable blockchain solution, and it has become a preferred platform for decentralized applications (dApps) and cross-border payments. For developers working with the Stellar network, integrating a wallet system is a key component for managing user interactions securely. The Stellar Wallet Kit offers a flexible solution for managing multiple Stellar wallets on your website, simplifying the process of connecting, signing, and submitting transactions.
In this blog post, weโll walk through how to integrate the Stellar Wallet Kit into your Stellar-based application, explaining the process step-by-step, and how it helps streamline wallet management and transaction signing.
The Stellar Wallet Kit is a tool designed to help developers integrate wallet functionality into their Stellar applications. It allows users to connect their wallets to a website and sign transactions using a simple interface. The Wallet Kit supports a variety of wallets in the Stellar ecosystem and offers both modal and non-modal implementation options for developers.
Letโs break down the process of integrating the Stellar Wallet Kit into your Stellar-based web application.
To get started, include the Stellar SDK in your HTML file or if youโre using a JavaScript framework, you can install the Stellar SDK through npm or yarn.
Or, if you're using npm:
or
And don't forget to install Stellar Wallets Kit dependency:
Once youโve installed the dependencies, initialize the Stellar Wallet Kit in your JavaScript code:
The allowAllModules() function doesn't import those modules where you need to provide a configuration (like WalletConnect), you will need to add them manually so check the folder src/modules to know all the available modules.
If you want to specify only the wallets you want to support, you can start the kit with only those by sending the modules to the constructor like this:
The library integrates a UI modal you can show your users after you have started the kit. Once they pick the wallet they want to use you can then use the other methods available. Here is how you can use it:
And as simple as that you will give full support to all the Stellar wallets plus you don't even need to handle the modal UI yourself.
The openModal method also lets you update multiple things about the model like the title, the allowed wallets or even the styles of it! Here are the accepted parameters:
Just like with the built-in modal component, the kit also includes a Button component that helps you to show an easy-to-use interface to your users so they can connect/disconnect their wallet while your site gets updates for when that happens. Here is how you can use it:
With just that you will include an interactive button on your website that will show the built-in modal to the user, fetch the public key, fetch the current XLM balance (if you provide a horizon URL), and give the user a UI to use!
You can see all the parameters you can include:
Each wallet has its own way when it comes to both requesting the public key and signing a transaction. Using this kit you can do both actions with a unified API:
Both methods will trigger the action using the wallet you have set before calling those methods.
Integrating the Stellar Wallet Kit into your Stellar-based application is a straightforward process that provides a secure, user-friendly way to manage wallet connections and transaction signing. By using this tool, developers can focus on building their applications without having to worry about managing the complexity of different wallets and transaction workflows.
Whether you're developing a payment system, a cross-border remittance app, or any other decentralized application on the Stellar network, the Wallet Kit is a powerful resource that enhances the user experience while ensuring secure and efficient blockchain interactions.
Resources: