A TypeScript library, CLI, and components for managing fungible and non-fungible tokens on Solana.
- ๐ช Fungible Tokens: Create, mint, transfer, and burn SPL tokens
- ๐จ NFT Collections: Full NFT lifecycle management with collections
- ๐ฌ Candy Machine: Launch NFT drops with guards and allowlists
- ๐๏ธ Compressed NFTs: Cost-effective cNFTs with Merkle trees
- ๐ฆ Zero Dependencies: Only official Solana packages required
- ๐ Fast: Built with performance in mind
- ๐ TypeScript: Fully typed with excellent DX
- ๐ ๏ธ Library & CLI: Use programmatically or from the command line
- โ๏ธ React Components: Ready-to-use wallet and token components
- ๐ Vue Components: Vue 3 components for token UIs
- ๐ Security First: Built-in security checks and best practices
# Using bun (recommended)
bun add ts-tokens
# Using npm
npm install ts-tokens
# Using yarn
yarn add ts-tokens
# Using pnpm
pnpm add ts-tokensimport { createToken, mintTokens } from 'ts-tokens'
// Create a new token
const token = await createToken({
name: 'My Token',
symbol: 'MTK',
decimals: 9,
initialSupply: 1_000_000_000n, // 1 billion tokens
})
console.log(`Token created: ${token.mint}`)
// Mint more tokens
await mintTokens({
mint: token.mint,
amount: 500_000_000n,
destination: recipientAddress,
})import { createCollection, mintNFT } from 'ts-tokens'
// Create a collection
const collection = await createCollection({
name: 'My NFT Collection',
symbol: 'MNFT',
uri: 'https://arweave.net/collection-metadata.json',
sellerFeeBasisPoints: 500, // 5% royalty
})
// Mint an NFT to the collection
const nft = await mintNFT({
name: 'NFT #1',
symbol: 'MNFT',
uri: 'https://arweave.net/nft-1-metadata.json',
collection: collection.mint,
sellerFeeBasisPoints: 500,
})
console.log(`NFT minted: ${nft.mint}`)# Configure your wallet
tokens config init
# Create a token
tokens create --name "My Token" --symbol "MTK" --decimals 9
# Mint tokens
tokens mint <mint-address> 1000000 --to <recipient>
# Create an NFT collection
tokens collection create --name "My Collection" --symbol "MNFT"
# Mint an NFT
tokens nft create --name "NFT #1" --collection <collection-address>
# Check balances
tokens balance <mint-address>Create a tokens.config.ts file in your project root:
import { defineConfig } from 'ts-tokens'
export default defineConfig({
// Blockchain settings
chain: 'solana',
network: 'devnet', // 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet'
// Wallet configuration
wallet: {
keypairPath: '~/.config/solana/id.json',
},
// Storage provider for metadata
storageProvider: 'arweave', // 'arweave' | 'ipfs' | 'shadow-drive'
// Transaction settings
commitment: 'confirmed',
autoCreateAccounts: true,
// Security
securityChecks: true,
dryRun: false,
})| Package | Description |
|---|---|
ts-tokens |
Core library and CLI |
@ts-tokens/react |
React components and hooks |
@ts-tokens/vue |
Vue 3 components and composables |
ts-governance |
DAO governance and voting |
Zero External Dependencies: Unlike Metaplex SDKs, ts-tokens only depends on official Solana packages (@solana/web3.js, @solana/spl-token). We implement all program interactions using raw instructions.
Better Developer Experience: Simpler APIs, better error messages, and TypeScript-first design.
Full Feature Parity: Everything you can do with Metaplex, you can do with ts-tokensโoften with less code.
// Metaplex: 3+ instructions, multiple accounts
// ts-tokens: 1 instruction, clean API
await createNFT({
name: 'My NFT',
royalty: 5, // 5% - not basis points!
})bun testPlease see our releases page for more information on what has changed recently.
Please see CONTRIBUTING for details.
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
For casual chit-chat with others using this package:
Join the Stacks Discord Server
โSoftware that is free, but hopes for a postcard.โ We love receiving postcards from around the world showing where tokens is being used! We showcase them on our website too.
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States ๐
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
The MIT License (MIT). Please see LICENSE for more information.
Made with ๐
