Stacks.js Overview
Stacks.js is an SDK for building on the Stacks blockchain. It's a collection of various JavaScript libraries allowing developers to interact with the Stacks blockchain or allow their users to.
There are two main ways developers build applications on the Stacks blockchain:
- 🔒 Without Direct Private Key Access: For example, a web app that allows users to interact with the Stacks blockchain using their Stacks wallet (browser extension or mobile). Read More in the Connect Guide
- 🔑 With Private Key Access: For example, managing funds with the Stacks.js CLI, building a backend (which can sign transactions directly).
Most users interact via their favorite Stacks wallet. Developers can build web apps, which prompt the user for an action (e.g. sign a transaction), and then the wallet will handle the rest. The wallet will act in the security, and best interest of the user, and the user will be able to review the transaction before signing.
Nevertheless, direct private key access is needed for some use cases. Developers can build simple scripts and tools intended for "offline" use. Users may use the Stacks.js CLI directly to send a transaction. Backends may need to automate signing without direct user interaction. In these cases, developers can use the same libraries used by Stacks wallets for account handling and transaction signing.
There are three main integrations used by Stacks enabled applications:
- Authentication: Register and sign users in with identities on the Stacks blockchain
- Transaction signing: Prompt users to sign and broadcast transactions to the Stacks blockchain
- Data storage: Save and retrieve data for users with Gaia
All three of these integrations can be used together to create powerful new user experiences that rival or exceed those of traditional apps while protecting your users' digital rights.
Stacks.js starters offer working templates with Stacks Connect pre-installed for a quick and easy way to get started with building Stacks enabled web apps.
References
Below is a list of all Stacks.js libraries and a few JS libraries and helpers maintained by Hiro:
Connecting Wallets
@stacks/connect
Connect web application to Stacks wallet browser extensions. Github
Stacks Primitives
@stacks/transactions
Construct, decode transactions and work with Clarity smart contracts on the Stacks blockchain. Github@stacks/wallet-sdk
Library for building wallets, managing accounts, and handling keys for the Stacks blockchain. Github@stacks/storage
Store and fetch files with Gaia, the decentralized storage system. Github@stacks/encryption
Encryption functions used by stacks.js packages. Github@stacks/auth
Construct and decode authentication requests for Stacks apps. Github@stacks/profile
Functions for manipulating user profiles. Github@stacks/network
Network and API library for working with Stacks blockchain nodes. Github@stacks/common
Common utilities used by stacks.js packages. Github
Native Smart Contract Interaction
@stacks/bns
Library for interacting with the BNS contract. Github@stacks/stacking
Library for PoX stacking. Github
Others
@stacks/cli
Command line interface to interact with auth, storage, and Stacks transactions. Github@stacks/blockchain-api-client
Auto-generated REST and websocket API for all endpoints provided by the Stacks Blockchain API. Github@stacks/keychain
DEPRECATED: replaced by@stacks/wallet-sdk
.
Development
There is a main Stacks.js monorepo containing most of the packages, but a few others often also considered as a part of "Stacks.js".
Are we missing anything? Feel free to open issues in the Github repositories.