F0x01 (pronounced "fox-zero-one") is a decentralized Pomodoro protocol built on Solana that uses financial incentives to encourage focused work. It enables users to create time-based focus commitments, stake tokens, track completed Pomodoro sessions, and earn rewards based on their commitment fulfillment.
# Clone the repository
git clone https://github.com/mahelika/fox-zero-one.git
cd f0x01
# Install dependencies
npm install
# Build the program
anchor build
# Run tests
anchor test
F0x01 incentivizes productive behavior through a token staking mechanism:
- Create Commitments: Stake tokens against your productivity goals
- Complete Pomodoro Sessions: Track 55-minute focus sessions on-chain
- Earn Rewards: Receive your stake back plus bonus rewards for high completion rates
- Build Streaks: Maintain and track daily activity streaks
The protocol consists of the following main components:
FocusProgram
: Global program state tracking total users, total staked amount, and reward parametersUserProfile
: Per-user state tracking sessions completed, rewards earned, and activity streaksFocusCommitment
: Individual commitment tracking staked amount and session requirementsSessionRecord
: Records of individual Pomodoro sessions
initialize_program
: Set up the program with token mint and reward parameterscreate_user_profile
: Create a new user profile to start participatingcreate_commitment
: Stake tokens against a new productivity commitmentstart_session
: Begin a new Pomodoro sessioncomplete_session
: Verify and record completion of a Pomodoro sessionclaim_rewards
: Claim rewards after completing a commitment
FocusChain uses Solana's Program Derived Addresses (PDAs) for secure token custody and verification:
- Token vaults are created for each commitment to securely hold staked tokens
- Sessions require adequate time and slot verification to prevent gaming the system
- Strict time constraints between sessions prevent cheating
- Daily sessions are tracked to ensure consistent productivity
Rewards are determined by your fulfillment rate:
- 90%+ completion: Return of staked amount + bonus reward (based on program reward rate)
- 75-89% completion: Return of full staked amount
- <75% completion: Partial refund (75% of staked amount)
- Create a user profile to start tracking stats
- Create a commitment by staking tokens and setting goals (sessions per day, total days)
- Start daily sessions and complete the required focused work (55 minutes per session)
- Build streaks by completing sessions across consecutive days
- Claim rewards after the commitment period ends
lib.rs # Program entry point and instruction routing
│
├── instructions/ # Program instructions
│ ├── initialize.rs # Initialize program state
│ ├── user.rs # User profile management
│ ├── commitment.rs # Commitment creation and reward claiming
│ └── session.rs # Session tracking and completion
│
├── state/ # Program state definitions
│ ├── program.rs # Global program state
│ ├── user_profile.rs # User-specific state
│ ├── commitment.rs # Commitment state
│ └── session.rs # Session state
│
└── error.rs # Custom program errors
The project is organized following standard Anchor project structure:
f0x01/
├── programs/ # Program source code
│ └── f0x01/
│ ├── src/
│ │ ├── lib.rs # Program entry point
│ │ ├── instructions/ # All instructions
│ │ ├── state/ # Program state
│ │ └── error.rs # Error definitions
│ └── Cargo.toml
├── tests/ # JavaScript tests
├── migrations/ # Deployment scripts
├── app/ # Frontend (if applicable)
├── target/ # Build artifacts
├── .anchor/ # Anchor configuration
├── Anchor.toml # Anchor settings
└── package.json # Project dependencies
# Build the program
anchor build
# Run the test suite
anchor test
The test suite includes comprehensive tests for:
- Program initialization
- User profile creation
- Commitment creation and staking
- Session starting and completion
- Reward claiming with different completion rates
- Streak calculation and verification
## 🛠️ Usage
### Creating a Commitment
```typescript
// Create a new commitment with 100 tokens, 4 sessions per day for 7 days
await program.methods
.createCommitment(
new BN(commitmentId),
new BN(100_000_000), // 100 tokens with 6 decimals
4, // sessions per day
7 // total days
)
.accounts({
commitment: commitmentPDA,
userProfile: userProfilePDA,
focusProgram: focusProgramPDA,
user: wallet.publicKey,
userTokenAccount: userTokenAccount,
vault: vaultPDA,
vaultAuthority: vaultAuthorityPDA,
tokenMint: focusTokenMint,
tokenProgram: TOKEN_PROGRAM_ID,
systemProgram: SystemProgram.programId,
rent: SYSVAR_RENT_PUBKEY,
})
.rpc();
// Start a new session
await program.methods
.startSession(new BN(sessionId))
.accounts({
commitment: commitmentPDA,
sessionRecord: sessionPDA,
userProfile: userProfilePDA,
user: wallet.publicKey,
systemProgram: SystemProgram.programId,
})
.rpc();
// After 55 minutes, complete the session
await program.methods
.completeSession()
.accounts({
sessionRecord: sessionPDA,
commitment: commitmentPDA,
userProfile: userProfilePDA,
user: wallet.publicKey,
})
.rpc();
F0x01 implements several verification mechanisms to ensure legitimate session completion:
- Time-based verification: Sessions must last at least 55 minutes
- Blockchain slot verification: Additional verification using Solana slot timing
- Session spacing: Minimum 30-minute gap between sessions
- Daily limits: Maximum sessions per day as defined in commitment
- Sessions are structured as two 25-minute focus periods with a 5-minute break (55 minutes total)
- The protocol uses Solana's native slot timing as an additional verification mechanism
- Activity streaks are tracked and reset based on continuous daily participation
- All token operations use secure PDA-based vaults with proper authority checks
- Frontend UI for easy interaction
- Mobile notifications for session tracking
- Social features for community accountability
- NFT rewards for milestone achievements
- Integration with productivity tools