Skip to content

Ethboxer/daily-relics

Repository files navigation

Daily Relics - Idle RPG on Base

An onchain idle RPG mini-game built as a Base Mini App. Check in daily, complete quests, craft relics, upgrade your hero, and climb the leaderboard.

Features

  • Daily Check-In: Onchain transaction minting a "Daily Sigil" with streak bonuses
  • Energy System: Offchain regen (+1 per 10 min), server-verified
  • Quests: 3 rotating daily quests (tap, time-based, social share)
  • Crafting: Spend materials to forge items; rare items recorded onchain
  • Upgrades: Spend Season Points onchain to boost drop rates, energy cap, quest slots
  • Leaderboard: Season points from onchain events + server-verified quest completions
  • Soulbound Badges: Streak milestone badges (7, 30, 100 days)

Tech Stack

  • Frontend: Next.js 14 (App Router), TypeScript, TailwindCSS
  • Web3: wagmi v2 + viem v2, Base mainnet + Base Sepolia
  • Backend: Next.js Route Handlers, Prisma + SQLite
  • Smart Contracts: Solidity + Foundry, OpenZeppelin-compatible
  • Auth: SIWE-style message signing with iron-session

Environment Variables

Copy .env.example to .env.local and fill in:

DATABASE_URL="file:./dev.db"
NEXT_PUBLIC_CHAIN="base-sepolia"           # "base" or "base-sepolia"
NEXT_PUBLIC_CONTRACT_ADDRESS="0x..."       # Deploy contract first
SESSION_SECRET="your-secret-32-chars-min"  # openssl rand -hex 32
NEXT_PUBLIC_APP_URL="http://localhost:3000"

Local Development

# 1. Install dependencies
npm install

# 2. Set up database
npx prisma generate
npx prisma db push

# 3. (Optional) Seed demo data
npm run db:seed

# 4. Start dev server
npm run dev

Open http://localhost:3000.

Deploy Smart Contract

Requires Foundry:

cd contracts

# Install dependencies (forge-std)
forge install foundry-rs/forge-std --no-commit

# Run tests
forge test -vvv

# Deploy to Base Sepolia
DEPLOYER_PRIVATE_KEY=0x... forge script script/Deploy.s.sol \
  --rpc-url https://sepolia.base.org \
  --broadcast --verify

# Deploy to Base Mainnet
DEPLOYER_PRIVATE_KEY=0x... forge script script/Deploy.s.sol \
  --rpc-url https://mainnet.base.org \
  --broadcast --verify

After deploying, update NEXT_PUBLIC_CONTRACT_ADDRESS in .env.local.

Deploy to Vercel

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel

# Set environment variables in Vercel dashboard:
# - DATABASE_URL (use Vercel Postgres or keep file-based for demo)
# - SESSION_SECRET
# - NEXT_PUBLIC_CHAIN
# - NEXT_PUBLIC_CONTRACT_ADDRESS
# - NEXT_PUBLIC_APP_URL

Base Mini App / Farcaster Manifest

The file public/.well-known/farcaster.json contains the required manifest.

Generate accountAssociation

  1. Go to base.dev and follow the Mini App registration flow
  2. Use the Farcaster CLI or SDK to generate the accountAssociation:
    # Using farcaster-cli (if available)
    farcaster sign-app-key --domain your-app.vercel.app
  3. Paste the header, payload, and signature values into public/.well-known/farcaster.json
  4. Update all URLs in the manifest to your actual deployed URL
  5. Redeploy to Vercel

base.dev Verification Checklist

  • /.well-known/farcaster.json is accessible at your domain
  • accountAssociation fields are filled with real values
  • homeUrl matches your deployed URL
  • iconUrl and imageUrl point to valid images
  • App loads in a frame context
  • Wallet connection works within the frame

Run Tests

# Server logic tests (Vitest)
npm test

# Smart contract tests (Foundry)
cd contracts && forge test -vvv

Project Structure

daily-relics/
├── contracts/              # Solidity + Foundry
│   ├── src/DailyRelics.sol
│   ├── test/DailyRelics.t.sol
│   └── script/Deploy.s.sol
├── prisma/
│   ├── schema.prisma
│   └── seed.ts
├── public/.well-known/
│   └── farcaster.json
├── src/
│   ├── app/                # Next.js App Router pages
│   │   ├── api/            # Route handlers
│   │   ├── quests/
│   │   ├── crafting/
│   │   ├── inventory/
│   │   ├── leaderboard/
│   │   └── settings/
│   ├── components/         # React components
│   ├── hooks/              # Custom hooks
│   ├── lib/                # Utilities & config
│   └── __tests__/          # Vitest tests
└── README.md

Game Design

Core Loop

  1. Connect wallet → Sign in (SIWE-style)
  2. Daily check-in (onchain tx) → earn Season Points + streak bonus
  3. Energy regenerates passively → spend on quests
  4. Complete quests → earn crafting materials
  5. Craft items → rare crafts recorded onchain
  6. Upgrade (onchain tx) → boost drop rates / energy / quest rewards
  7. Climb the leaderboard by accumulating points

Onchain Actions

  • checkIn() — once per UTC day, emits CheckedIn event
  • upgrade(type) — spend points, emits Upgraded event
  • recordRareCraft(user) — milestone tracking, emits RareItemCrafted
  • Streak badges auto-minted at 7/30/100 day milestones

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors