stacks.JS

Decentralized app development made easy

The essential JavaScript libraries for apps on Stacks.

Modular core packages for identity, authentication, storage, transactions, stacking, and more

JS bindings for integrating with the Hiro Wallet for Web and leveraging all Stacks blockchain features

Rapidly integrate Clarity smart contracts into your apps

Sample Packages

@stacks/transactions

Construct, sign, and broadcast a Stacks transactions from a backend

import {
 makeContractCall,
 broadcastTransaction,
} from '@stacks/transactions';

const transaction = await makeContractCall({
 contractAddress: address,
 contractName: 'hello-world',
 functionName: 'set-id',
 functionArgs: [bufferCVFromString('3')],
 senderKey: 'abcxyz',
 network,
});

const broadcastResponse = await broadcastTransaction(transaction, network);
const txId = broadcastResponse.txid;
@stacks/connect

Authenticate users through a Stacks-compatible wallet

import { showConnect } from '@stacks/connect';


// authenticate user
showConnect({
 appDetails: {
  name: ”my-app”,
  icon: 🚀,
 },
 redirectTo: ”/dashboard”,
 userSession: userSession,
});
@stacks/blockchain-api-client

Read or broadcast to the Stacks blockchain

import { TransactionApi } from "@stacks/blockchain-api-client";

client = new TransactionsApi(config);

// get a transaction by id
const transaction = await client.getTransactionById({ txid: '0xabc123' });
@stacks/storage

With Hiro Wallet, you can securely lock your STX to participate in Stacking, either stacking by yourself or in a pool.

import { Storage } from ’@stacks/storage’;

const storage = new Storage({ userSession });

// store a text file on a user account
await storage.putFile(”hello-world.txt”, ”Hello, Bob!”);

Construct, sign, and broadcast Stacks transactions from a backend

import {
 makeContractCall,
 broadcastTransaction,
} from '@stacks/transactions';

const transaction = await makeContractCall({
 contractAddress: address,
 contractName: 'hello-world',
 functionName: 'set-id',
 functionArgs: [bufferCVFromString('3')],
 senderKey: 'abcxyz',
 network,
});

const broadcastResponse = await broadcastTransaction(transaction, network);
const txId = broadcastResponse.txid;

Authenticate users through a Stacks-compatible wallet

import { showConnect } from '@stacks/connect';


// authenticate user
showConnect({
 appDetails: {
  name: ”my-app”,
  icon: 🚀,
 },
 redirectTo: ”/dashboard”,
 userSession: userSession,
});

Read or broadcast to the Stacks blockchain

import { TransactionApi } from "@stacks/blockchain-api-client";

client = new TransactionsApi(config);

// get a transaction by id
const transaction = await client.getTransactionById({ txid: '0xabc123' });

Store and fetch files with Gaia, the decentralized Stacks storage system

import { Storage } from ’@stacks/storage’;

const storage = new Storage({ userSession });

// store a text file on a user account
await storage.putFile(”hello-world.txt”, ”Hello, Bob!”);
Keep, send, and receive tokens
Web
Desktop
Buy STX
Web
Connect to apps
Web
Participate in Stacking
Desktop
Secure your assets with Ledger
Desktop

Hiro Wallet is everything you need to manage your tokens and collectibles and will protect your tokens when you use apps.

Hiro Wallet is everything you need to manage your tokens and collectibles and will protect your tokens when you use apps.

Code with ((( Clarity

Clarity is a programming language that brings smart contracts to Bitcoin. It’s optimized for security and predictability, and it gives developers a safe way to build complex smart contracts. Clarity is designed for high-stakes code where bugs are not an option.

Built with Stacks.js

“Stacks.js is the building block that we use all the time to build, broadcast, and sign our transactions.”

Philip De Smedt,
Arkadiko Core Contributor

Developer Resources

Discord

Talk with like-minded developers building on Stacks.

Join #dev-general

Github

See the open source Stacks.js repository.

Stacks.js repo