Quickstart
Learn how to transfer STX tokens via a web wallet using Stacks Connect.
In this quickstart guide, you will learn how to set up your project, authenticate users with a web wallet, and initiate a STX token transfer.
For a deeper dive into the authentication process, check out the authenticate users guide.
Install package dependencies
Add the @stacks/connect, @stacks/transactions, and @stacks/network packages to your project using your preferred package manager.
Create an AppConfig and UserSession
Add a reusable UserSession instance to your project. This will allow your app to store authentication state in localStorage.
You can now import the userSession instance in the following step to continue with the authentication process.
Interacting with the user's wallet
The process of connecting to a wallet gives the web app information about the wallet account, which enables interactions with the Stacks blockchain, like calling smart contracts.
Using the showConnect function, you can prompt the user to select a wallet to connect to your app.
This will configure the showConnect function to display a wallet connection pop-up with your app's name and icon, and handle user confirmation or cancellation actions in the onFinish and onCancel callbacks.
Initiate a STX transfer
With a connected wallet, you can now initiate a STX transfer to another account.
To prompt the user for a STX transfer call, use the openSTXTransfer function.
This will prompt the user to confirm and sign a transaction, sending 10 STX to the recipient address.
The amount field is denominated in microSTX, which is the smallest fraction of STX. 1,000,000 microSTX = 1 STX.