Status: β Fully Functional Smart Contracts | π§ͺ 47/47 Tests Passing | π Ready for Testnet
Quest Tavern is a decentralized security audit platform built on Stacks that connects security researchers (hunters) with blockchain projects seeking audits. Projects create audit quests with token rewards, hunters submit vulnerability findings, and rewards are distributed based on finding severity and impact.
# Install dependencies
npm install
# Run all tests
npm test
# Check contract syntax
clarinet check
# Deploy to testnet
clarinet deployments apply --testnet- Create Audit Quests with custom token rewards (STX, sBTC, or any SIP-010 token)
- Review & Approve Findings with flexible reward percentages
- Escrow Integration for secure fund management
- Cancel Quests before hunters join (full refund)
- Join Quests to participate in audits
- Submit Findings with 5 severity levels (Critical to Info)
- Earn Rewards based on finding impact
- Track Stats including total earnings and findings accepted
- Multi-token Support: STX, sBTC, and whitelisted SIP-010 tokens
- Escrow System: Secure lock/release/refund operations
- Platform Fee: 5% fee on distributed rewards
- On-chain Verification: All findings and proofs stored on-chain via IPFS hashes
LedgerGuard/
βββ contracts/
β βββ quest-manager.clar # Core quest lifecycle (430+ lines)
β βββ escrow.clar # Token escrow system (280+ lines)
β βββ token-whitelist.clar # Payment token registry (240+ lines)
β βββ test-token.clar # SIP-010 test token
β βββ traits/
β βββ quest-trait.clar # Quest operations interface
βββ tests/
β βββ quest-manager.test.ts # 23 unit tests
β βββ escrow.test.ts # 19 unit tests
β βββ integration.test.ts # 5 integration tests
βββ docs/
β βββ Dev.MD # Architecture & roadmap
β βββ CONTRACT_README.md # Contract specifications
βββ DEPLOYMENT.md # Deployment guide
βββ Clarinet.toml # Project configuration
All 47 Tests Passing β
- β Quest Manager: 23 tests covering creation, joining, findings, rewards, cancellation
- β Escrow: 19 tests covering locking, releasing, refunding, batch operations
- β Integration: 5 tests covering complete workflows and edge cases
Main contract managing the audit quest lifecycle:
- Quest creation with token support
- Hunter registration and tracking
- Finding submission with severity levels (1-5)
- Approval/rejection with custom reward percentages
- Automated reward distribution
- Platform fee collection (5%)
Multi-token escrow system:
- Lock tokens for quest rewards
- Release to hunters after approval
- Refund to tavernmasters on cancellation
- Batch release for multiple recipients
- Token whitelist integration
Registry of approved payment tokens:
- Add/remove tokens with metadata
- Enable/disable tokens
- Admin management system
- Pre-configured: STX, sBTC
;; Create audit quest with 1M test tokens, 100 block duration
(contract-call? .quest-manager create-quest-with-token
"https://github.com/my-project/smart-contracts"
u1000000
'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test-token
u100
)
;; Returns: (ok u1) - quest ID;; Register as hunter for quest #1
(contract-call? .quest-manager join-quest u1)
;; Returns: (ok true);; Submit critical vulnerability
(contract-call? .quest-manager submit-finding
u1 ;; quest-id
u1 ;; severity (1=Critical)
0x1234... ;; description IPFS hash
0x5678... ;; proof IPFS hash
)
;; Returns: (ok u1) - finding ID;; Approve finding with 40% of reward pool
(contract-call? .quest-manager approve-finding
u1 ;; finding-id
u40 ;; reward percentage
)
;; Returns: (ok true);; After quest ends and rewards distributed
(contract-call? .quest-manager payout-finding-with-token u1)
;; Returns: (ok true) + transfers tokens to hunterPublic Functions
create-quest/create-quest-with-token- Create new audit questjoin-quest- Register as huntersubmit-finding- Submit vulnerabilityapprove-finding- Approve with reward %reject-finding- Reject with reasondistribute-rewards- Finalize quest (owner only)payout-finding/payout-finding-with-token- Claim rewardcancel-quest- Cancel before hunters join
Read-Only Functions
get-quest- Quest detailsis-quest-active- Check if activeget-finding- Finding detailsget-hunter-stats- Hunter statistics
Public Functions
lock-tokens/lock-stx- Lock fundsrelease-tokens- Release to recipientrefund-escrow- Refund to depositorbatch-release- Release to multiple recipientsadd-token-to-whitelist- Add approved token
Read-Only Functions
get-escrow- Escrow detailsis-escrow-locked- Check lock status
Quest Manager
100: Unauthorized101: Quest not found102: Quest ended103: Quest cancelled104: Already joined105: Not a hunter106: Invalid severity107-115: Finding/reward errors
Escrow
100: Unauthorized101: Invalid amount102: Token not whitelisted103-108: Escrow state errors
Before mainnet deployment:
- Professional security audit of all contracts
- Token transfer logic verification
- Economic model validation
- Gas optimization review
See DEPLOYMENT.md for full security considerations.
- Dev.MD - Development roadmap and architecture
- CONTRACT_README.md - Detailed contract specifications
- DEPLOYMENT.md - Deployment guide with examples
- Stacks Documentation - Stacks blockchain docs
- Clarity Language - Smart contract language guide
- Clarinet v2.0+
- Node.js 18+
- npm or yarn
# Clone repository
git clone <repository-url>
cd LedgerGuard
# Install dependencies
npm install
# Run tests
npm test
# Check contracts
clarinet check
# Start Clarinet console
clarinet console# Run all tests
npm test
# Run specific test file
npx vitest run tests/quest-manager.test.ts
# Run with coverage
npm test -- --coverage
# Watch mode for development
npx vitest watch# Generate deployment plan
clarinet deployments generate --testnet
# Deploy contracts
clarinet deployments apply --testnetSee DEPLOYMENT.md for detailed mainnet deployment instructions.
- Core contract architecture
- Quest lifecycle management
- Escrow system with multi-token support
- Token whitelist registry
- SIP-010 token integration
- Complete test suite (47 tests)
- Integration tests
- Documentation
- Testnet deployment
- User acceptance testing
- Security audit
- Mainnet deployment
- Frontend dApp
- IPFS integration for finding storage
- Quest templates
- Reputation system
- Multi-signature approvals
- Automated severity classification
This is a demonstration project for the Quest Tavern audit platform. For production use:
- Conduct professional security audits
- Test thoroughly on testnet
- Review all economic parameters
- Consider additional security measures
See project documentation for license information.
Built with:
- Stacks: Bitcoin L2 blockchain
- Clarity: Smart contract language
- Clarinet: Development environment
- Vitest: Testing framework