A blockchain-powered fighting game built on Linera, featuring real-time combat with on-chain state management and Dynamic Labs wallet integration.
LineraFight is a wave-based fighting game where players:
- Connect their wallet and claim a Linera microchain
- Start a game with a wager
- Fight through waves of enemies
- Cash out their winnings or keep fighting for higher rewards
The game state (wager, wave progress, results) is stored on-chain using Linera's innovative microchain architecture, while the combat mechanics run locally for a smooth gameplay experience.
linerafight/
├── contract/ # Rust smart contract (Linera)
│ ├── src/
│ │ ├── lib.rs # ABI definitions & operations
│ │ ├── contract.rs # Main contract logic
│ │ ├── state.rs # State definitions (Player, etc.)
│ │ └── service.rs # GraphQL query service
│ └── Cargo.toml
├── frontend/ # React + TypeScript frontend
│ ├── src/
│ │ ├── game/ # Game components (Board, Controls, etc.)
│ │ ├── context/ # GameContext for Linera integration
│ │ ├── lib/ # Linera adapter & Dynamic signer
│ │ └── pages/ # Landing, Game pages
│ └── package.json
└── deploy.sh # Deployment script
| Layer | Technology |
|---|---|
| Blockchain | Linera - Microchain architecture |
| Smart Contract | Rust + linera-sdk |
| Frontend | React 18, TypeScript, Vite |
| Styling | TailwindCSS |
| Wallet | Dynamic Labs - Embedded wallet support |
| Animations | GSAP, Anime.js, Motion |
The Linera smart contract supports these operations:
| Operation | Description |
|---|---|
StartGame { wager } |
Start a new game with the specified wager |
Battle |
Progress through a battle wave |
EndWave |
End the game and cash out |
Reset |
Reset player state |
- Rust (for contract compilation)
- Linera CLI (for deployment)
- Node.js 18+ (for frontend)
# Build and deploy to Linera testnet
./deploy.shThis will compile the Rust contract and deploy it to the Linera Conway testnet.
cd frontend
npm install
npm run devThe app will be available at http://localhost:5173
Create a .env file in the frontend directory:
# Dynamic Labs Environment ID
VITE_DYNAMIC_ENVIRONMENT_ID=your-dynamic-environment-id
# Linera Testnet Faucet
VITE_LINERA_FAUCET_URL=https://faucet.testnet-conway.linera.net- Wallet Connection: Users connect via Dynamic Labs (supports MetaMask, email login, etc.)
- Chain Claim: A new Linera microchain is claimed for the user from the faucet
- Game Start: The
startGamemutation is sent on-chain with the wager amount - Gameplay: Combat runs locally for smooth UX (no per-hit transactions)
- Game End: The
endWavemutation finalizes the game state on-chain
User Action → Chain Transaction
─────────────────────────────────────────
Start Game → startGame(wager)
Hit/Attack → (local only)
Game Over / Cash Out → endWave
The project includes a vercel.json for proper SPA routing and COOP/COEP headers required for SharedArrayBuffer:
{
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "Cross-Origin-Opener-Policy", "value": "same-origin" },
{ "key": "Cross-Origin-Embedder-Policy", "value": "credentialless" }
]
}
]
}MIT
- Linera for the blockchain infrastructure
- Dynamic Labs for wallet integration
- Built with ❤️ for the Linera ecosystem