[WIP] Build web strategy game with Stellar Soroban contracts#1
Merged
Conversation
Copilot stopped work on behalf of
leocagli due to an error
February 22, 2026 16:02
Collaborator
|
Ok |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/contracts/vault_wars/src/lib.rs,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)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.