On-chain habit tracking with accountability on Stacks
- What is AhhbitTracker?
- How It Works
- Tech Stack
- Getting Started
- Deploy to Vercel
- Contract Reference
- Security
- Documentation
- Contributing
- License
AhhbitTracker is a decentralized habit-tracking dApp on the Stacks blockchain. Stake STX as a financial commitment to daily habits. Miss a day — your stake is forfeited to a shared pool. Complete a 7-day streak — reclaim your stake and earn bonuses from forfeited stakes.
Live contract: SP1N3809W9CBWWX04KN3TCQHP8A9GN520BD4JMP8Z.habit-tracker-v2
- Stake — Create a habit and deposit ≥ 0.02 STX as your commitment
- Check In — Record daily completion within the 24-hour window (~144 blocks)
- Streak — Maintain a 7-day streak to unlock withdrawal
- Withdraw — Reclaim your stake and claim your share of the bonus pool
Missed check-ins forfeit your stake to the shared pool, distributed as rewards to users who complete their streaks.
| Layer | Technology |
|---|---|
| Smart Contract | Clarity 2.0 on Stacks Mainnet |
| Frontend | React 18 · TypeScript · Vite 5 · Tailwind CSS |
| State | @tanstack/react-query |
| Wallet | @stacks/connect (Leather · Xverse · Asigna) |
| Testing | Vitest + Clarinet SDK |
| Deployment | Vercel |
Prerequisites: Node.js ≥ 18, Clarinet CLI
git clone https://github.com/Yusufolosun/AhhbitTracker.git
cd AhhbitTracker
npm install
cd frontend
cp .env.example .env.local
npm install
npm run dev # → http://localhost:3000npm test # Run contract and integration tests
cd frontend && npm test # Run frontend tests (30 tests)
clarinet check # Validate Clarity syntaxThe repository now supports three explicit runtime stages without committing secrets:
developmentstagingproduction
Use stage templates as your starting point and keep real values in local-only files:
# Root scripts (deployment and automation)
cp .env.development.example .env.development.local
cp .env.staging.example .env.staging.local
cp .env.production.example .env.production.local
# Frontend (Vite)
cp frontend/.env.development.example frontend/.env.development.local
cp frontend/.env.staging.example frontend/.env.staging.local
cp frontend/.env.production.example frontend/.env.production.local
# Mobile (Expo)
cp mobile/.env.development.example mobile/.env.development.local
cp mobile/.env.staging.example mobile/.env.staging.local
cp mobile/.env.production.example mobile/.env.production.local*.local env files are gitignored. Commit only *.example templates and never commit mnemonics, private keys, or secret API credentials.
| Package | Description |
|---|---|
stx-utils |
Zero-dependency utility library for Stacks — formatting, validation, block math, address helpers |
ahhbit-tracker-sdk |
Typed SDK for the AhhbitTracker contract — transaction builders, read-only queries, post-conditions |
defikit |
DeFi utility toolkit for basis points, fee math, slippage, AMM and token amount helpers |
cd frontend
npm run build # → frontend/dist/
npm run preview # Preview locally- Import the repository in Vercel
- Set Root Directory →
frontend - Build settings are auto-detected from
vercel.json - Optionally override
VITE_CONTRACT_ADDRESS/VITE_CONTRACT_NAME
| Function | Description |
|---|---|
create-habit |
Create a habit with STX stake |
check-in |
Record daily check-in |
withdraw-stake |
Reclaim stake after 7-day streak |
claim-bonus |
Claim share of forfeited pool |
get-habit |
Read habit details |
get-pool-balance |
View total forfeited STX |
get-unclaimed-completed-habits |
View pending bonus claimant count |
get-estimated-bonus-share |
View next estimated bonus share |
Full reference → docs/API_REFERENCE.md
- Post-condition validation on every STX transfer
- On-chain authorization — only habit owners can check in, withdraw, or claim
- Input validation enforced in the smart contract
- No private keys, mnemonics, or secrets in this repository
See docs/SECURITY.md for the full security model.
| Document | Description |
|---|---|
| User Guide | End-user walkthrough |
| API Reference | Contract functions and error codes |
| Architecture | System design and data flow |
| FAQ | Common questions |
| Security | Security model |
Pull requests are welcome. See CONTRIBUTING.md.