Skip to content

thirdweb-example/web3-warlords

Repository files navigation

⚔️ Web3 Warlords

A streamlined blockchain strategy game showcasing thirdweb API capabilities. Built without any blockchain SDKs - pure API calls only!

Web3 Warlords Next.js TypeScript Tailwind

🎮 Game Features

🌍 10x10 Territory Grid

  • Simple strategic battlefield
  • 3 territory types: Keep, Outpost, Stronghold
  • Real-time territory claiming and battles

⚔️ Army System

  • 4 army types: Infantry, Archer, Cavalry, Siege
  • Different movement ranges and combat strengths
  • Risk-style battle mechanics

Action Points System

  • Simple resource: Action Points (AP)
  • All actions cost AP: Claim (20), Recruit (15), Move (5), Battle (10)
  • Auto-regenerating - no complex economy management

🎯 Streamlined Gameplay

  • Focus on strategy, not resource micromanagement
  • Quick battles and expansion
  • Landing page with game overview and thirdweb CTAs
  • Easy to learn, fun to master
  • Easy to learn, fun to master

🚀 Pure API Architecture

This is a showcase for thirdweb customers - demonstrating what's possible with pure API calls:

  • ✅ No Web3 SDKs required
  • ✅ No complex blockchain setup
  • ✅ No backend servers needed
  • ✅ No databases required
  • ✅ Just HTTP requests + smart contracts

Perfect for developers exploring api.thirdweb.com capabilities!

🛠️ Environment Setup

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

# Get from https://thirdweb.com/dashboard
THIRDWEB_CLIENT_ID=your_client_id_here
THIRDWEB_SECRET_KEY=your_secret_key_here

# Deploy contract first, then add address
NEXT_PUBLIC_GAME_CONTRACT=0x...

# Network (Base Sepolia)
NEXT_PUBLIC_CHAIN_ID=84532

🎯 Quick Start

  1. Install dependencies:

    npm install
  2. Deploy contract (use thirdweb dashboard)

    • Deploy the /contracts/Web3Warlords.sol contract
    • Add contract address to .env.local
  3. Run the game:

    npm run dev
  4. Explore:

    • Landing page at http://localhost:3000
    • Game interface at http://localhost:3000/game

🏗️ Architecture Highlights

Simplified Blockchain State

  • Game state → Single smart contract
  • Action Points → Simple counter system
  • Real-time updates → Polling blockchain via API
  • Persistence → Blockchain storage

API-First Development

Every feature is just an HTTP request:

// Get game state
const state = await fetch("/api/game/state?player=0x...");

// Claim territory
await fetch("/api/game/actions", {
  method: "POST",
  body: JSON.stringify({ action: "claimTerritory", territoryId: 5 }),
});

// Recruit army
await fetch("/api/game/actions", {
  method: "POST",
  body: JSON.stringify({ action: "recruitArmy", territoryId: 1, armyType: 0 }),
});

// Start battle
await fetch("/api/game/actions", {
  method: "POST",
  body: JSON.stringify({ action: "battle", fromId: 1, toId: 2 }),
});

🎨 Visual Design

  • Clean modern UI with dark theme
  • Territory grid with visual indicators
  • Action Points meter showing resource status
  • Intuitive controls for strategy gameplay

🔥 thirdweb APIs Showcased

Authentication - Wallet connection
Wallets - Balance checking, transaction management
Contracts - Read/write operations, event monitoring
Transactions - Status tracking, gas optimization

Comprehensive Web3 integration - all via API calls!

🎯 Perfect For Learning

This game shows how to build:

  • Simple blockchain games
  • Action-based game mechanics
  • Real-time Web3 apps
  • Strategy game logic

All with just API calls - no complex Web3 setup required!

📜 Open Source

This is a showcase project demonstrating thirdweb API capabilities. Feel free to:

  • Fork and modify
  • Add new features
  • Use as learning reference
  • Build your own Web3 games

Let's show the world what's possible with powerful APIs! 🚀

About

Guest authentication and contract interaction via API

Resources

Stars

Watchers

Forks