Production-ready decentralized fundraising on Stacks. Users can connect wallets using Stacks Connect or WalletConnect via Reown AppKit.
Live Demo: fundraiser-d-app-kappa.vercel.app
- Overview
- Architecture
- Technology Stack
- Prerequisites
- Quick Start
- Usage Guide
- Smart Contract Details
- Configuration
- Testing
- Contributing
- Learning Resources
- Stacks Builder Challenge #3
- Security
- License
- Acknowledgments
- Multi-Wallet Support (WalletConnect)
The Stacks FundRaiser dApp enables decentralized fundraising on Bitcoin L2 using Stacks smart contracts. Users contribute STX to campaigns with transparent on-chain tracking and a clear, accessible interface.
- Secure wallet integration via
@stacks/connect(Leather and Xverse) and optional WalletConnect using Reown AppKit ^1.8.15 - Smart contract backed (Clarity on Stacks Testnet)
- Real-time fundraising progress and personal contribution tracking
- Modern UI using shadcn/ui and Tailwind CSS
- Testnet/Mainnet switchable configuration
- Responsive layout optimized for desktop and mobile
- Fast builds and HMR with Vite
graph TB
A[User Browser] --> B[Vite React App]
B --> C[Stacks Connect]
C --> D[Wallet Extension]
D --> E[Stacks Network]
B --> F[Smart Contract]
F --> G[Clarity Functions]
G --> H[Stacks Blockchain]
I[Contract Owner] --> J[Withdraw Function]
J --> F
subgraph "Frontend Layer"
B
C
end
subgraph "Blockchain Layer"
F
G
H
end
subgraph "User Interaction"
A
D
I
end
sequenceDiagram
participant U as User
participant F as Frontend
participant W as Wallet
participant C as Smart Contract
participant B as Blockchain
U->>F: Click Donate
F->>W: Request Transaction
W->>U: Show Transaction Details
U->>W: Approve Transaction
W->>C: Execute fund() function
C->>B: Update Balance
B->>C: Confirm Transaction
C->>F: Return Success
F->>U: Show Confirmation
flowchart TD
A[User Input] --> B[Form Validation]
B --> C[STX to MicroSTX Conversion]
C --> D[Transaction Building]
D --> E[Wallet Signing]
E --> F[Broadcast to Network]
F --> G[Contract Execution]
G --> H[State Update]
H --> I[UI Refresh]
I --> J[Real-time Display]
K[Read Operations] --> L[Contract Calls]
L --> M[Data Fetching]
M --> N[UI Components]
- Frontend Framework: React 18 with TypeScript
- Build Tool: Vite for fast development and optimized production builds
- Styling: Tailwind CSS with shadcn/ui component library
- State Management: React Query for server state management
- Form Handling: React Hook Form with Zod validation
- Wallet Connection:
@stacks/connectv7.10.2 (Stacks Connect for Leather/Xverse) - Transaction Handling:
@stacks/transactionsv6.17.0 - Network Configuration:
@stacks/networkv6.17.0 - Smart Contracts: Clarity language on Stacks blockchain
- Multi-Wallet Support: Integrated wallet connection using
@reown/appkit^1.8.15,@reown/appkit-adapter-bitcoin^1.8.15, and@reown/appkit-adapter-wagmi^1.8.15 for enhanced compatibility
- WalletConnect via Reown AppKit ^1.8.15 for broader wallet compatibility and multi-chain support.
- Linting: ESLint with TypeScript rules
- Code Formatting: Prettier (via ESLLint config)
- Package Manager: pnpm
- Type Checking: TypeScript strict mode
Before you begin, ensure you have the following installed:
- Node.js: Version 18.0.0 or higher
- pnpm: Modern package manager (install via
npm install -g pnpm) - Git: Version control
- Stacks Wallet: Leather or Xverse browser extension
For testing the fundraiser functionality:
- Visit the Stacks Testnet Faucet
- Connect your testnet wallet
- Request STX tokens for testing donations
git clone <your-repository-url>
cd stacks-fundraiser2pnpm installpnpm devNavigate to http://localhost:5173 to see the application running.
- Click "Connect Wallet" in the app
- Approve the connection in your wallet extension
- Make a test donation with STX tokens
- Connect Wallet: Use the "Connect Wallet" button to link your Leather or Xverse wallet
- View Progress: See the current fundraising progress and goal
- Make Donation: Enter STX amount and confirm the transaction
- Track Contribution: View your personal donation history
- Deploy Contract: Deploy the Clarity smart contract to Stacks network
- Configure App: Update contract address in
src/lib/stacks.ts - Launch Campaign: Set your fundraising goal and start accepting donations
- Withdraw Funds: Use the owner controls to withdraw collected STX
- Network: Stacks Testnet
- Address:
STGDS0Y17973EN5TCHNHGJJ9B31XWQ5YXBQ0KQ2Y.fund-raiser - Owner:
STGDS0Y17973EN5TCHNHGJJ9B31XWQ5YXBQ0KQ2Y - Language: Clarity
| Function | Type | Parameters | Description |
|---|---|---|---|
fund |
Public | amount: uint |
Donate STX to the fundraiser |
withdraw |
Public | None | Owner-only: Withdraw all collected funds |
get-balance |
Read-only | None | Returns current total balance in microSTX |
get-goal |
Read-only | None | Returns the fundraising goal in microSTX |
get-owner |
Read-only | None | Returns the contract owner's address |
get-donor-amount |
Read-only | donor: principal |
Returns a specific donor's total contribution |
- Owner-only Withdrawals: Only the contract owner can withdraw funds
- Immutable Goal: Fundraising goal is set at deployment and cannot be changed
- Transparent Tracking: All donations are publicly visible on-chain
- No External Dependencies: Pure Clarity implementation with no external calls
To deploy on Mainnet, update src/lib/stacks.ts:
// Change to true for mainnet deployment
export const IS_MAINNET = true;
// Update contract details for mainnet
export const CONTRACT_ADDRESS = "YOUR_MAINNET_CONTRACT_ADDRESS";
export const CONTRACT_OWNER = "YOUR_MAINNET_OWNER_ADDRESS";Create a .env.local file for custom configurations:
# Optional: Custom API endpoints
VITE_STACKS_API_URL=https://api.mainnet.stacks.co
VITE_STACKS_EXPLORER_URL=https://explorer.stacks.co# Run unit tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Run E2E tests (if configured)
pnpm test:e2e- Wallet connection works with Leather
- Wallet connection works with Xverse
- Donation transaction completes successfully
- Balance updates in real-time
- Progress bar reflects correct percentage
- Owner withdrawal works for contract owner
- Error handling for insufficient funds
- Network switching between testnet/mainnet
We welcome contributions from the Stacks community! This project is designed to help builders learn and collaborate.
- π Bug Reports: Found an issue? Open a GitHub issue
- β¨ Feature Requests: Have an idea? Start a discussion
- π§ Code Contributions: See our Contributing Guide
- π Documentation: Help improve this README or add tutorials
- π§ͺ Testing: Add test cases or help with QA
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Ensure all tests pass:
pnpm test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- TypeScript: Strict type checking enabled
- ESLint: All linting rules must pass
- Prettier: Code formatting via ESLint
- Conventional Commits: Use semantic commit messages
- Stacks Documentation - Official Stacks docs
- Clarity Language Guide - Learn smart contract development
- React Documentation - Frontend framework basics
- Stacks.js SDK - JavaScript libraries
- Stacks Connect - Wallet integration guide
- Stacks Explorer - Blockchain explorer
- Stacks University - Educational content
- Discord Community - Get help from the community
- GitHub Discussions - Ask questions here
This project is optimized for maximum rewards in the Stacks Builder Challenge #3!
Rewards are based on your leaderboard position, determined by activity across:
- Deployed Contracts: Quality and complexity of Clarity smart contracts
- On-chain Activity: Transaction volume and user engagement
- Contract Design: Security, efficiency, and innovative features
- @stacks/connect Integration: Seamless wallet connections
- @stacks/transactions: Contract interaction patterns
- @stacks/network: Proper network configuration and handling
- Public Repository Activity: Code commits, issues, and pull requests
- Documentation Quality: Comprehensive READMEs and guides
- Community Engagement: Helping other builders and learners
- Emphasize @stacks/connect usage: wallet connection patterns implemented
- Robust @stacks/transactions usage: contract calls with error handling
- Production practices: TypeScript, tests, documentation
- Open source focus: issues, PRs, discussions welcomed
- Educational value: learning resources and clear docs
- Uses
@stacks/connectv7.10.2 and@stacks/transactionsv6.17.0 (see package.json) - Optional support for Reown AppKit (WalletConnect). Recommended version range:
^1.0.0 - Public repository activity encouraged via issues and pull requests
- Smart contract activity visible via Stacks Explorer
- Audit ready: follows Clarity best practices
- Access control: owner-only functions enforced
- Input validation: parameters validated before execution
- Type safety: full TypeScript coverage
- Input sanitization: validated and sanitized inputs
- Wallet security: no private keys stored; operations via wallet
- Post conditions: implement for production
- Error handling: comprehensive across the app
- Testing: thorough before mainnet deployment
This project is licensed under the MIT License - see the LICENSE file for details.
- Stacks Foundation for the blockchain infrastructure
- Hiro Systems for developer tools and wallet integration
- shadcn for the UI component library
- The Stacks community for support and inspiration
Built for the Stacks ecosystem.
This project supports wallet connections via Stacks Connect (@stacks/connect) for Stacks-native wallets and Reown AppKit for broader multi-wallet and multi-chain experiences.
- Package:
@reown/appkit^1.8.15 (recommended version range:^1.8.15) - React bindings:
@reown/appkit-react
Install:
pnpm add @reown/appkit@^1.8.15 @reown/appkit-react@^1.8.15Notes:
- Users can connect using both Stacks Connect for Stacks-native wallets (Leather/Xverse) and Reown AppKit for broader wallet compatibility, aligning with leaderboard tracking for "Use of WalletKit SDK or Reown AppKit".
- Refer to official Reown documentation for initialization and provider configuration.

