Snippets
Ready-to-use code examples for building on Stacks and Bitcoin
To explore Snippets with AI, copy and paste llms.txt into your LLM of choice.
Transactions
Token Transfers
- Transfer STX - Send STX tokens between addresses
- Transfer a SIP-10 token - Transfer fungible tokens
Transaction Building
- Build an unsigned transaction - Create transactions for hardware wallets
- Create a sponsored transaction - Pay fees on behalf of users
Post-Conditions
- Build a STX post-condition - Secure STX transfers
- Build an FT post-condition - Secure fungible token transfers
- Build an NFT post-condition - Secure NFT transfers
Smart Contracts
Contract Deployment
- Deploy a contract - Deploy contracts to the blockchain
Clarity Functions
- Create SHA256 hash - Generate hashes in Clarity
- Filter items from a list - List manipulation in Clarity
- Generate random number - Pseudo-random numbers in contracts
- Check for duplicates - Find duplicate items in lists
- Return an entry from a map - Access map data structures
- Helper function to restrict contract calls - Access control patterns
Accounts & Addresses
Wallet Management
- Generate a wallet - Create new wallet with mnemonic
- Generate a secret key - Create private keys
- Get account details from wallet - Extract account information
Address Utilities
- Convert BTC to STX address - Cross-chain address conversion
- Convert string to principal - Parse principal addresses
- Derive Stacks address from keys - Generate addresses from key pairs
- Derive principal addresses between networks - Network address mapping
- Create a random burn address - Generate burn addresses
Cryptography & Security
Hashing
- Create SHA256 hash (Stacks.js) - Generate hashes in JavaScript
- Create SHA256 hash (Clarity) - Generate hashes in smart contracts
API Integration
- Integrate API keys using Stacks.js - Secure API key usage
Development Tools
Testing
- Fetch testnet Bitcoin on regtest - Get test BTC for development