Skip to content

JoshMayerr/dots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ValueAgar

On-chain escrow + off-chain skill game (Agar-style) with USDC buy-ins and EIP-712 voucher payouts.

Overview

ValueAgar is a minimal prototype demonstrating trustless custody and payouts (on-chain) with responsive gameplay (off-chain). Players pay $1 USDC to join a 10-minute round of an Agar.io-style game. In-game value (credits) transfers off-chain via gameplay. Players can "Retire & Bank" to lock their value, and at round end, the server signs an EIP-712 payout voucher that players can use to claim USDC from the on-chain escrow contract.

Trust Model

  • Smart Contract: Escrow + payouts — trustless
  • Server: Gameplay referee + voucher signer — trusted for fairness (transparent and deterministic)
  • Client: Untrusted (display + inputs only)

Architecture

  • Contracts: Solidity smart contracts deployed on testnet (Sepolia or L2)
  • Server: Node.js/TypeScript game server with WebSocket and REST API
  • Web: React frontend with Web3 integration

Setup

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Hardhat for contract deployment
  • Testnet wallet with test USDC

Environment Variables

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

  • RPC_URL: Ethereum RPC endpoint
  • CHAIN_ID: Chain ID (e.g., 11155111 for Sepolia)
  • USDC_ADDRESS: USDC ERC-20 token address on testnet
  • CONTRACT_ADDRESS: Deployed DemoValueAgar contract address
  • SERVER_PRIVKEY: Private key for voucher signing (EOA)
  • ENTRY_FEE: Entry fee in token units (1000000 = 1.0 USDC with 6 decimals)
  • SESSION_LENGTH_MS: Session duration in milliseconds (600000 = 10 minutes)
  • JOIN_CLOSE_MS: Join window close time before session end (120000 = 2 minutes)
  • TICK_RATE: Game tick rate per second (30)
  • SNAPSHOT_RATE: Snapshot broadcast rate per second (12)

Contracts

cd contracts
npm install
npx hardhat compile
npx hardhat test
npx hardhat run scripts/deploy.ts --network sepolia

Server

cd server
npm install
npm run build
npm start

Web

cd web
npm install
npm run dev

Demo Flow

  1. Lobby: Connect wallet, approve USDC, join session
  2. Arena: Play game, move around, eat other players, accumulate credits
  3. Retire & Bank: Lock your credits (optional, can wait for round end)
  4. Settle: Fetch voucher, claim USDC from contract

Acceptance Criteria

  • User can connect wallet on testnet
  • User can approve 1 USDC and call join(sessionId)
  • User can enter Arena and move around
  • User can eat/transfer value and see HUD update
  • User can click "Retire & Bank" to freeze value
  • User can fetch voucher and successfully claim USDC from contract

Limitations

  • Demo/testnet only — no real money
  • Server is trusted for gameplay fairness
  • Single server instance (no distributed consensus)

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors