Get the current GameHub contract address
Address - The GameHub contract addressfn get_hub(env: soroban_sdk::Env) -> soroban_sdk::Address
Set a new GameHub contract address
new_hub - The new GameHub contract addressfn set_hub(env: soroban_sdk::Env, new_hub: soroban_sdk::Address)
Update the contract WASM hash (upgrade contract)
new_wasm_hash - The hash of the new WASM binaryfn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Get game information.
session_id - The session ID of the gameGame - The game statefn get_game(env: soroban_sdk::Env, session_id: u32) -> Result
Get the current admin address
Address - The admin addressfn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address
Set a new admin address
new_admin - The new admin addressfn set_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
Start a new game between two players with points. This creates a session in the Game Hub and locks points before starting the game.
CRITICAL: This method requires authorization from THIS contract (not players).
The Game Hub will call game_id.require_auth() which checks this contract's address.
session_id - Unique session identifier (u32)player1 - Address of first playerplayer2 - Address of second playerplayer1_points - Points amount committed by player 1player2_points - Points amount committed by player 2fn start_game(
env: soroban_sdk::Env,
session_id: u32,
player1: soroban_sdk::Address,
player2: soroban_sdk::Address,
player1_points: i128,
player2_points: i128,
) -> Result<(), soroban_sdk::Error>
Submit a Rock, Paper, or Scissors move for the current game. Each player may only submit once. The game resolves when both have moved.
session_id - The session ID of the gameplayer - Address of the player submitting a movegame_move - The chosen move: Rock, Paper, or Scissorsfn submit_move(
env: soroban_sdk::Env,
session_id: u32,
player: soroban_sdk::Address,
game_move: PlayerMove,
) -> Result<(), soroban_sdk::Error>
Initialize the contract with GameHub address and admin
admin - Admin address (can upgrade contract)game_hub - Address of the GameHub contractfn __constructor(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
game_hub: soroban_sdk::Address,
)
Reveal the winner once both players have submitted their moves. Rock beats Scissors, Scissors beats Paper, Paper beats Rock. On a tie, moves are reset and players must submit again (returns Ok(None)).
session_id - The session ID of the gameOption<Address> - Some(winner) if decided, None if tied (moves reset)fn reveal_winner(
env: soroban_sdk::Env,
session_id: u32,
) -> Result