Scaffold-Stacks is a developer-friendly toolkit for building decentralized applications (dApps) on the Stacks blockchain, inspired by Scaffold-ETH. It provides a pre-configured stack to accelerate Stacks dApp development, featuring a React frontend, Clarity smart contracts, Stacks.js for blockchain interactions, and Clarinet for local testing and deployment. Build Bitcoin-secured dApps—like DeFi, NFTs, or decentralized identity—with ease, leveraging Stacks’ unique connection to Bitcoin’s security and finality.
- Rapid Prototyping: Jumpstart your Stacks dApp with a ready-to-use template, similar to Scaffold-ETH but tailored for Stacks’ Bitcoin layer.
- Clarity Smart Contracts: Write secure, predictable smart contracts in Clarity, with examples for common use cases (e.g., Bitcoin-backed NFTs, BNS domains).
- Bitcoin Integration: Build dApps that settle on Bitcoin, using Stacks’ Proof-of-Transfer (PoX) and upcoming sBTC for trustless Bitcoin interactions.
- Developer-Friendly: Includes a React frontend with Stacks.js, local testing with Clarinet, and clear documentation for beginners and pros alike.
- Community-Driven: Inspired by Scaffold-ETH’s ethos, Scaffold-Stacks encourages contributions to grow the Stacks developer ecosystem.
- Frontend: React app with Stacks.js for wallet connections (Hiro Wallet) and contract interactions.
- Smart Contracts: Example Clarity contracts for minting NFTs, managing BNS domains, and basic DeFi (e.g., lending with BTC collateral).
- Testing: Clarinet for local contract testing and deployment to Stacks’ testnet.
- Wallet Integration: Connects to Hiro Wallet for STX transactions and Bitcoin-anchored operations.
- Bitcoin Awareness: Contracts can read Bitcoin’s state (e.g., verify BTC transactions) using Clarity’s native functions.
Before you start, ensure you have the following installed:
- Node.js (v16 or later)
- Yarn (or npm)
- Clarinet (Stacks’ smart contract development tool)
- Hiro Wallet (browser extension for Stacks)
- Rust (required for Clarity development)
- Docker (optional, for running a local Stacks node)
- A code editor like VSCode with the Clarity extension
Follow these steps to set up and run Scaffold-Stacks locally.
git clone https://github.com/your-username/scaffold-stacks.git
cd scaffold-stacksNote: Replace your-username with the actual repository owner if forked.
Install frontend and Clarinet dependencies:
# Install React app dependencies
cd packages/frontend
yarn install
# Install Clarinet (if not globally installed)
cd ../contracts
clarinet checkStart a local Stacks blockchain for development using Clarinet or Docker:
# Using Clarinet
cd packages/contracts
clarinet integrate
# OR using Docker (alternative)
docker-compose up -dThis spins up a local Stacks node, Bitcoin node, and API at http://localhost:20443.
Deploy the example Clarity contracts to the local network:
cd packages/contracts
clarinet deploy --network devnetThis deploys contracts like nft-mint.clar and simple-defi.clar to your local Stacks node.
Launch the React frontend to interact with your dApp:
cd packages/frontend
yarn startOpen http://localhost:3000 in your browser. Connect your Hiro Wallet to interact with the deployed contracts.
Run unit tests for Clarity contracts:
cd packages/contracts
clarinet testThis executes tests in the tests/ directory, ensuring your contracts behave as expected.
scaffold-stacks/
├── packages/
│ ├── contracts/ # Clarity smart contracts and tests
│ │ ├── contracts/ # Clarity contract files (e.g., nft-mint.clar)
│ │ ├── tests/ # Clarinet test files
│ │ ├── Clarinet.toml # Clarinet configuration
│ │ └── settings/ # Deployment settings
│ ├── frontend/ # React frontend
│ │ ├── src/ # React components, hooks, and Stacks.js integration
│ │ ├── public/ # Static assets
│ │ └── package.json # Frontend dependencies
├── docker-compose.yml # Docker setup for local Stacks node
└── README.md # This file
Scaffold-Stacks includes example contracts to kickstart your project:
- Bitcoin-Backed NFT: Mint NFTs on Stacks that require a Bitcoin transaction as payment, verified via Clarity’s Bitcoin state-reading capabilities.
- Simple DeFi: A lending protocol where users deposit STX as collateral and borrow against BTC, with transactions settled on Bitcoin.
- BNS Domain Manager: Register and manage .btc domains using Stacks’ Blockchain Naming System.
To explore these, check the contracts in packages/contracts/contracts/ and their frontend interfaces in packages/frontend/src/components/.
Customize your setup by editing these files:
packages/contracts/Clarinet.toml: Configure network settings (devnet, testnet, mainnet).packages/frontend/src/config.js: Update contract addresses and API endpoints.docker-compose.yml: Adjust ports or node settings for the local Stacks environment.
To deploy to Stacks’ testnet:
- Update
Clarinet.tomlto use the testnet network. - Fund your Hiro Wallet with testnet STX via the Stacks faucet.
- Deploy contracts:
cd packages/contracts
clarinet deploy --network testnet- Update
packages/frontend/src/config.jswith the testnet contract addresses and API (https://api.testnet.hiro.so).
We welcome contributions to make Scaffold-Stacks better! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Make your changes and commit (
git commit -m "Add your feature"). - Push to your fork (
git push origin feature/your-feature). - Open a pull request with a clear description of your changes.
Please follow the code of conduct and check the contributing guidelines.
- Stacks Documentation – Official Stacks developer guides.
- Clarity Documentation – Learn Clarity and Clarinet.
- Stacks.js – Library for frontend integration.
- Hiro Wallet – Wallet for STX and Bitcoin transactions.
- Stacks Community – Join the Stacks Discord or X (@Stacks).
- Scaffold-ETH – Inspiration for this project.
This project is licensed under the MIT License.
- Built with ❤️ by the Stacks developer community.
- Thanks to Hiro Systems for Clarinet, Stacks.js, and developer tools.
Happy building on Stacks! 🚀 For issues or questions, open a GitHub issue or reach out on the Stacks Discord.