Skip to content

[WIP] Build web strategy game with Stellar Soroban contracts#1

Merged
leocagli merged 1 commit into
mainfrom
copilot/create-game-smart-contracts
Feb 22, 2026
Merged

[WIP] Build web strategy game with Stellar Soroban contracts#1
leocagli merged 1 commit into
mainfrom
copilot/create-game-smart-contracts

Conversation

Copilot AI commented Feb 22, 2026

Copy link
Copy Markdown
Contributor
  • Create Soroban Rust smart contract (/contracts/vault_wars/src/lib.rs, types.rs)
  • Create Noir ZK circuits (/circuits/state_transition.nr, final_score.nr)
  • Create React/TypeScript frontend (/frontend/src/GameUI.tsx, CommitPanel.tsx, TurnLog.tsx)
  • Create Clawbot bot engine (/bot/clawbot.ts)
  • Create deployment and simulation scripts (/scripts/deploy.ts, simulate.ts)
  • Update README with project description
Original prompt

Perfecto. Te dejo un contexto completo listo para pegar en GitHub Copilot / GitHub AI / Cursor / Claude Code / etc.
Está escrito como SPEC técnica ejecutable, no como explicación, para que la IA genere repo directamente.

📦 CONTEXTO COMPLETO — CLawbot Strategy Game (Stellar ZK Hackathon)

PROJECT NAME

clawbot-vault-wars

🎯 OBJECTIVE

Build a minimal playable web strategy game using:
• Stellar Soroban smart contracts
• Zero Knowledge proofs as CORE gameplay mechanic
• commit-reveal turn system
• hidden player state verified via ZK
• frontend UI playable by judges
• compatible with hackathon Game Hub (start_game() / end_game())

The game must demonstrate:

hidden information
provable outcomes
verifiable state transitions
no trusted server

🧠 GAME CONCEPT

Vault Wars

Two players (human or AI Clawbot).

Each turn:
• choose action secretly
• commit hash onchain
• later reveal + ZK proof
• contract verifies state update

After fixed turns → highest credits wins.

🎮 GAME RULES (MVP SAFE VERSION)

PLAYER PRIVATE STATE

energy: uint8 (0..10)
credits: uint8 (0..50)
shield: uint8 (0..10)
turn: uint8

Stored privately.

Only hash stored onchain:

state_root = PoseidonHash(state)

ACTIONS (KEEP EXACT)

FARM

requires energy >=1
energy -=1
credits +=2

ATTACK

requires energy >=2
energy -=2

if opponent_shield >0:
opponent_shield -=1
else:
opponent_credits -=2

FORTIFY

requires energy >=1
energy -=1
shield +=2

🔁 TURN FLOW

STEP 1 — COMMIT

Player submits:

commit = Poseidon(
action,
salt,
prev_state_root,
turn
)

Call contract:

commit_move(game_id, commit)

STEP 2 — REVEAL + PROOF

Player submits:

action
salt
new_state_root
zk_proof

Proof must verify:

I know previous private state
such that:

hash(previous_state) == prev_state_root

AND applying action produces new_state

AND hash(new_state) == new_state_root

AND all game rules respected

STEP 3 — CONTRACT VALIDATES

Contract checks:

hash(action,salt,prev_root,turn) == commit
verify_zk_proof(...)

If valid:

player_state_root = new_state_root

🏁 GAME END

After:

MAX_TURNS = 8

Players submit:

final_score_proof

Proof demonstrates:

credits value inside final state_root

Contract compares → winner.

Call:

end_game()

🤖 CLAWBOT ROLE

Clawbot is:

offchain decision engine

Each turn:

observe public game state
load private state
decide best action
generate salt
generate zk proof
submit reveal

For MVP:

Use simple heuristic:

if credits < 10 → FARM
if opponent likely weak → ATTACK
else → FORTIFY

🧾 REQUIRED SMART CONTRACT API

Must be Soroban Rust.

create_game()

fn create_game(player1)

join_game()

fn join_game(game_id, player2)

Must call:

start_game()

commit_move()

fn commit_move(game_id, player, commit_hash)

Store per turn.

reveal_move()

fn reveal_move(
game_id,
player,
action,
salt,
new_root,
zk_proof
)

Verify:
• commit match
• proof valid

Update root.

finalize_game()

Verify final proofs.

Determine winner.

Call:

end_game()

🧱 REPO STRUCTURE REQUIRED

/contracts
/vault_wars
src/lib.rs
src/types.rs

/circuits
state_transition.nr
final_score.nr

/frontend
/src
GameUI.tsx
CommitPanel.tsx
TurnLog.tsx

/bot
clawbot.ts

/scripts
deploy.ts
simulate.ts

🔐 ZK IMPLEMENTATION TARGET

Use one of:

Noir
RISC Zero
Halo2
SnarkJS

Preferred:

Noir (fastest for hackathon)

Circuit must support:

private:
previous_state
action
salt

public:
prev_root
new_root

🎨 FRONTEND REQUIREMENTS

Must show:
• create game
• join game
• commit button
• reveal button
• action selector
• turn counter
• proof verification status

Must allow:

human vs bot
bot vs bot

🎥 VIDEO DEMO REQUIREMENTS

Must show:
1. start game
2. commit hidden actions
3. reveal with ZK verification
4. game ends
5. winner shown

Must clearly say:

No trusted server
All moves cryptographically verified

🚨 IMPORTANT CONSTRAINTS FOR AI GENERATING CODE

When writing code:
• keep state small
• avoid floats
• avoid loops >10
• avoid dynamic arrays
• use fixed struct size
• deterministic rules only
• minimal storage

Game must compile and run locally first.

🏆 FINAL ONE-LINE DESCRIPTION (PUT IN README)

Clawbot Vault Wars is a two-player strategy game where hidden resource states and moves are verified with zero-knowledge proofs on Stellar, enabling fair autonomous agent gameplay without revealing private strategies.

✅ END OF CONTEXT


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@leocagli leocagli marked this pull request as ready for review February 22, 2026 16:02
@leocagli leocagli merged commit ea3105b into main Feb 22, 2026
1 check failed
Copilot AI requested a review from leocagli February 22, 2026 16:02
Copilot stopped work on behalf of leocagli due to an error February 22, 2026 16:02
@leocagli

Copy link
Copy Markdown
Collaborator

Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants