npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sol-anchor-gen

v0.1.0

Published

CLI tool for generating Anchor program scaffolding for Solana development with production-ready templates

Downloads

142

Readme

SolAnchorGen

   _____ ____  __       ___                __                 ______
  / ___// __ \/ /      /   |  ____  _____/ /_  ____  _____  / ____/__  ____
  \__ \/ / / / /      / /| | / __ \/ ___/ __ \/ __ \/ ___/ / / __/ _ \/ __ \
 ___/ / /_/ / /___   / ___ |/ / / / /__/ / / / /_/ / /    / /_/ /  __/ / / /
/____/\____/_____/  /_/  |_/_/ /_/\___/_/ /_/\____/_/     \____/\___/_/ /_/

Scaffold Solana Anchor programs with production-ready templates

A command-line scaffolding tool that generates boilerplate Anchor programs with common patterns and best practices.

Overview

SolAnchorGen accelerates Solana program development by providing production-ready templates for common use cases, saving hours of setup time. Built with TypeScript and powered by pnpm.

Features

  • 🚀 Quick Scaffolding - Generate complete Anchor programs in seconds
  • 📦 6 Production-Ready Templates - NFT, Staking, Escrow, Governance, Marketplace, Vault
  • Security Best Practices - Built-in validation, overflow protection, access control
  • 🧪 Comprehensive Tests - Full test coverage with Mocha/Chai
  • 📚 Complete Documentation - Inline comments, README, and usage examples
  • 🔧 Customizable Options - Template-specific configuration (e.g., token decimals)
  • 💻 TypeScript SDK - Client libraries for easy program interaction
  • 🎨 Beautiful CLI - Colorful output with progress indicators and spinners
  • 📋 Interactive Mode - Step-by-step project creation with prompts
  • Fast Setup - pnpm for lightning-fast dependency installation

Available Templates

  • NFT Minting - Complete NFT collection with metadata
  • Token Staking - Stake tokens and earn rewards
  • Escrow - Secure peer-to-peer token swaps
  • Governance - DAO voting and proposal system
  • Marketplace - Buy/sell NFTs with royalties
  • Vault - Secure token custody with multi-sig

Prerequisites

  • Node.js >= 18.0.0
  • pnpm (required package manager)
  • Anchor framework (for building generated programs)

Quick Start

# 1. Install pnpm if not already installed
npm install -g pnpm

# 2. Clone and build the project
git clone https://github.com/ayudhinc/SolAnchorGen.git
cd SolAnchorGen
pnpm install
pnpm build

# 3. Link globally for CLI usage
pnpm link --global

# 4. Generate your first project
sol-anchor-gen list                                    # See all templates
sol-anchor-gen init                                    # Interactive mode
sol-anchor-gen new --template nft-minting my-project   # Direct generation

Installation

Option 1: Install from npm (Recommended)

Install globally from npm:

npm install -g sol-anchor-gen

# Verify installation
sol-anchor-gen --version

Option 2: Install from source

Clone and build from source:

# Install pnpm
npm install -g pnpm

# Clone repository
git clone https://github.com/ayudhinc/SolAnchorGen.git
cd SolAnchorGen

# Install dependencies and build
pnpm install
pnpm build

# Link globally
pnpm link --global

# Verify installation
sol-anchor-gen --version

Usage

# Interactive mode
sol-anchor-gen init

# Generate specific template
sol-anchor-gen new --template nft-minting my-nft-program

# List all available templates
sol-anchor-gen list

# Generate with custom options
sol-anchor-gen new --template staking --token-decimals 9 my-staking-program

Example

$ sol-anchor-gen new --template nft-minting my-collection

✓ Created Anchor workspace
✓ Generated program code
✓ Added test suite
✓ Configured Anchor.toml

Your NFT minting program is ready!

Next steps:
  cd my-collection
  anchor build
  anchor test

Development

# Install dependencies
pnpm install

# Build the project
pnpm build

# Watch mode for development
pnpm dev

# Run the CLI locally
pnpm start

# Link for global usage
pnpm link --global

Project Status

Production Ready - All 6 templates are fully implemented with production-ready Rust programs, comprehensive tests, TypeScript SDKs, and detailed documentation.

Template Structure

Each template includes:

  • Rust Program Code - Production-ready Anchor programs with:
    • Security best practices (account validation, signer checks, overflow protection)
    • Custom error types with descriptive messages
    • Event emissions for tracking
    • Inline comments explaining security considerations
  • TypeScript SDK - Client library for easy program interaction
  • Comprehensive Test Suite - Full test coverage with Mocha/Chai
  • Anchor Configuration - Pre-configured Anchor.toml
  • Package Configuration - Ready-to-use package.json with pnpm
  • Documentation - Detailed README with usage examples and deployment instructions

Template Details

NFT Minting

  • Initialize NFT collections with metadata
  • Mint individual NFTs with unique URIs
  • SPL Token integration
  • Collection tracking

Token Staking

  • Configurable token decimals
  • Time-based reward calculation
  • Stake/unstake functionality
  • Reward claiming with automatic distribution

Escrow

  • Peer-to-peer token swaps
  • PDA-based vault for security
  • Initialize, exchange, and cancel operations
  • Atomic swap execution

Governance

  • DAO initialization with custom parameters
  • Proposal creation and voting
  • Token-weighted voting system
  • Quorum and approval threshold validation
  • Execution delay for security

Marketplace

  • List NFTs with custom pricing
  • Automatic royalty distribution (up to 50%)
  • Buy, cancel, and update listing operations
  • Creator royalty support

Vault

  • Multi-signature authorization (M-of-N)
  • Configurable guardian threshold
  • Withdrawal proposal and approval workflow
  • Secure token custody

Project Structure

SolAnchorGen/
├── src/
│   ├── cli/          # CLI infrastructure (commander, prompts)
│   ├── commands/     # Command handlers (init, new, list)
│   ├── generator/    # Workspace generation orchestration
│   ├── templates/    # Template implementations
│   ├── utils/        # Utilities (fs, validation, progress)
│   └── index.ts      # CLI entry point
├── dist/             # Compiled output
├── package.json      # Project configuration
└── tsconfig.json     # TypeScript configuration

Publishing to npm

To publish this package to npm:

# 1. Ensure you're logged in to npm
npm login

# 2. Build the project
pnpm build

# 3. Publish to npm (prepublishOnly script will run automatically)
npm publish

# Or for a dry run to see what would be published
npm publish --dry-run

Contributing

Want to add a new template? Check out our contribution guide.

License

MIT