Skip to content

bayyubenjamin/basetc

Repository files navigation

BaseTC Console

BaseTC Console is a Web3 mining simulation game designed specifically as a Farcaster Mini App and Frame. This project enables users to participate in an on-chain gamified ecosystem on the Base network, featuring activities such as Rig NFT purchasing, staking, mining, PvP battles, and social interactions via the Farcaster protocol.

License Next.js Farcaster Solidity

📋 Table of Contents

📖 About the Project

BaseTC Console serves as the frontend interface for interacting with the BaseTC suite of Smart Contracts. The application detects the user's environment (User Agent) to ensure access is mediated through supported clients such as Warpcast or the Base App. It integrates Web3 wallet authentication and the Farcaster social graph to provide a seamless user experience.

🛠 Architecture & Tech Stack

The project is built using a modern architecture that separates Client-Side, Server-Side, and On-Chain Logic.

Frontend & Framework

  • Core Framework: Next.js 14 (App Router).
  • Language: TypeScript.
  • Styling: Tailwind CSS & PostCSS.
  • State Management: React Query (@tanstack/react-query).

Web3 & Blockchain Integration

  • Interaction Libraries: Wagmi & Viem for EVM interactions.
  • Wallet Connection: ConnectKit.
  • Smart Contract Integration: Custom Hooks & EIP-712 Typed Data Signing for secure off-chain verification (SpinVault).

Farcaster Integration

  • SDK: @farcaster/miniapp-sdk for Mini App integration.
  • Viral Loop: Integrated sdk.actions.openUrl to trigger "Cast to Claim" flows.

🚀 Key Features

Based on the codebase structure, here are the system's core capabilities:

  1. Mining Simulation: The core mechanism where users manage "Rigs" to earn tokens.
  2. ⚔️ Battle Arena (PvP): A wagering system where users battle for $BaseTC using their Rig NFTs.
  3. ⚡ Overclock Hazard: A "push-your-luck" minigame where users overclock their rigs for massive multipliers.
  4. 🎰 Social Spin & Cast: Daily reward system powered by EIP-712 signatures and Farcaster social actions.
  5. NFT Integration: Utilization of RigNFT (ERC-1155) with tiered attributes (Basic, Pro, Legend).
  6. Staking: Time-locked asset staking with NFT-based yield boosts (StakingVault).
  7. Environment Gating: Automatic client detection (Warpcast, Base, Ethereum) to restrict access from bots.

🆕 New Features (v1.3.0)

  • Overclock Hazard: A single-player risk management game. Users can increase their reward multiplier but face a growing risk of rig failure.
  • Integrated Game Hub: A new tabbed navigation system within the Arena component allowing seamless switching between PvP Battles and Overclocking.
  • Battle Arena PvP: Real-time betting lobbies where the winner takes 95% of the pot. Win probability is calculated based on RNG + Rig Power.
  • Cast-to-Claim: Users must "Cast" their spin results to Warpcast to unlock Leaderboard points, creating a strong viral loop.

🎮 Game Mechanics

1. Battle Arena (PvP)

Users can create or join lobbies with fixed bet amounts (e.g., 10, 50, 100 $BaseTC).

  • Winner Take All: The winner receives 190% of the bet amount (Total Pot - 5% Treasury Fee).
  • Power Calculation: Your chance of winning increases based on the NFTs you hold:
    • Base Power: 10
    • Basic Rig: +1 point
    • Pro Rig: +5 points
    • Legend Rig: +20 points
  • Fairness: The battle logic uses on-chain randomness (block.prevrandao) combined with user power scores.

2. Overclock Hazard

A high-stakes minigame integrated into the Arena hub.

  • Multiplier Levels: Users progress through tiers (1.2x, 1.8x, 3.5x, 8.0x) by "Overclocking" their system.
  • Risk Management: Each level increases the chance of failure. If the system fails, the initial bet is lost.
  • NFT Safety Boost: Holding RigNFTs provides a safety buffer, reducing the failure risk percentage based on the rig tier.
  • Cashout: Users can secure their current profit at any level before the next attempt.

3. Social Spin

A "Spin & Cast" mechanic designed for retention and virality.

  • Ticket System: Users get free spins based on Epochs or Referrals.
  • Flow:
    1. Spin: User signs a message; the backend verifies eligibility and generates an EIP-712 signature.
    2. On-Chain Claim: User submits the signature to SpinVault to receive tokens.
    3. Cast: User is prompted to share the win on Farcaster.
    4. Points: Once casted, leaderboard points are credited via the MiniApp SDK.

⛓ Smart Contracts

The repository includes Solidity source code (app/api/solidity/) which forms the foundation of the on-chain logic:

Contract Function Description
BaseTC.sol The main ERC-20 token of the ecosystem.
BattleArena.sol PvP Logic, Lobby management, and Power calculation.
OverclockHazard.sol (New) Multi-level risk game logic with NFT-based safety modifiers.
SpinVault.sol EIP-712 Secured reward distribution for the Spin feature.
RigNFT.sol ERC-1155 contract with BASIC, PRO, and LEGEND tiers.
StakingVault.sol Logic for staking tokens with time-locks and NFT boosts.
GameCore.sol Primary game logic and interaction orchestration.
ReferralClaimer.sol On-chain referral reward distribution.
TreasuryVault.sol Management of protocol treasury and revenue.

📂 Project Structure

basetc-console/
├── app/
│   ├── api/             # API Routes (Next.js) & Solidity Contracts
│   │   ├── frame/       # Endpoints for Farcaster Frames
│   │   ├── solidity/    # Smart Contract source code
│   │   ├── sign-event-action/ # Backend signer for EIP-712
│   │   └── ...          
│   ├── components/      # React UI Components
│   │   ├── Arena.tsx    # Integrated Game Hub (PvP & Overclock)
│   │   ├── OverclockGame.tsx # Overclock Hazard Minigame
│   │   ├── Spin.tsx     # Spin & Cast Interface
│   │   └── ...
│   ├── context/         # React Context (Web3Provider, FarcasterProvider)
│   ├── lib/             # Utilities, ABIs (JSON), and client configuration
│   └── page.tsx         # Entry point with client detection logic
├── public/              # Static assets
└── supabase/            # Supabase Configuration & Edge Functions

🔵 Base Ecosystem Integration
This project is proudly built on Base L2 and designed for the Farcaster ecosystem.

Tech Stack Highlights
Network: Base Mainnet

Framework: Next.js 14 + Farcaster Frames

Integration: Coinbase Smart Wallet & Wagmi

Track: Base Builders January Sprint

Deployed and verified for the Base Builders community.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •