Contract feee457c765f3523b252fc90254f746b6c1cf491f659f577163e11527f200354

← Back to Index 📥 Download WASM

Meta

cliver 25.1.0#
rssdkver 25.0.2#59a2e01a26f9330f8d516690911cb2ca87a6f1b3
rsver 1.93.0

Interface

Get the current GameHub contract address

Returns

  • Address - The GameHub contract address
fn get_hub(env: soroban_sdk::Env) -> soroban_sdk::Address

Set a new GameHub contract address

Arguments

  • new_hub - The new GameHub contract address
fn set_hub(env: soroban_sdk::Env, new_hub: soroban_sdk::Address)

Update the contract WASM hash (upgrade contract)

Arguments

  • new_wasm_hash - The hash of the new WASM binary
fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)

Get game information.

Arguments

  • session_id - The session ID of the game

Returns

  • Game - The game state
fn get_game(env: soroban_sdk::Env, session_id: u32) -> Result

Get the current admin address

Returns

  • Address - The admin address
fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address

Set a new admin address

Arguments

  • new_admin - The new admin address
fn 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.

Arguments

  • session_id - Unique session identifier (u32)
  • player1 - Address of first player
  • player2 - Address of second player
  • player1_points - Points amount committed by player 1
  • player2_points - Points amount committed by player 2
fn 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.

Arguments

  • session_id - The session ID of the game
  • player - Address of the player submitting a move
  • game_move - The chosen move: Rock, Paper, or Scissors
fn 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

Arguments

  • admin - Admin address (can upgrade contract)
  • game_hub - Address of the GameHub contract
fn __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)).

Arguments

  • session_id - The session ID of the game

Returns

  • Option<Address> - Some(winner) if decided, None if tied (moves reset)
fn reveal_winner(
    env: soroban_sdk::Env,
    session_id: u32,
) -> Result, soroban_sdk::Error>

Imports

WebAssembly Text (WAT) ▶