Skip to content

stacksjs/ts-tokens

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

34 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Social Card of this repo

npm version GitHub Actions Commitizen friendly

ts-tokens

A TypeScript library, CLI, and components for managing fungible and non-fungible tokens on Solana.

Features

  • ๐Ÿช™ 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

Install

# Using bun (recommended)
bun add ts-tokens

# Using npm
npm install ts-tokens

# Using yarn
yarn add ts-tokens

# Using pnpm
pnpm add ts-tokens

Quick Start

Create a Fungible Token

import { 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,
})

Create an NFT Collection

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}`)

CLI Usage

# 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>

Configuration

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,
})

Packages

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

Documentation

Why ts-tokens?

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!
})

Testing

bun test

Changelog

Please see our releases page for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discussions on GitHub

For casual chit-chat with others using this package:

Join the Stacks Discord Server

Postcardware

โ€œ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 ๐ŸŒŽ

Sponsors

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.

License

The MIT License (MIT). Please see LICENSE for more information.

Made with ๐Ÿ’™

About

Fungible or non-fungible. Choose your network.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Contributors 3

  •  
  •  
  •