Contract c92c31eedc675ee13ac2c5e874d22077c9754e48c6d3734576e1e26ddc9099ff

← Back to Index 📥 Download WASM

Meta

rssdkver 23.1.0#7456be9d91fe1f4cb070fc2732bac78244ce6c3f
rsver 1.91.1

Instances

  • CCDE3GHIZHPLLB5G44XHEYB3XLPW7MX7ZVP62JD25WDUAS4ICCGOCT7D

Interface

Commit a choice for the current round

Commitment = keccak256(choice || salt || session_id || round) where choice is 0, 1, or 2 as a single byte

fn commit(
    env: soroban_sdk::Env,
    session_id: u32,
    player: soroban_sdk::Address,
    commitment: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>

Reveal a choice for the current round

The contract verifies that keccak256(choice || salt || session_id || round) matches the player's commitment.

fn reveal(
    env: soroban_sdk::Env,
    session_id: u32,
    player: soroban_sdk::Address,
    choice: u32,
    salt: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>

Update the contract WASM hash (upgrade contract)

fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)

Get the current admin address

fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address

Get match information

fn get_match(
    env: soroban_sdk::Env,
    session_id: u32,
) -> Result

Get current queue status

fn get_queue(env: soroban_sdk::Env) -> Option

Set a new admin address

fn set_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)

Find a match - either join queue (maker) or match with waiting player (taker)

If no one is waiting: Player joins queue, returns Queued If someone is waiting: Match is created, returns Matched(session_id, opponent)

Wager amount must be specified. For now, any wager matches any other. Future: Could add wager-tier matching.

fn find_match(
    env: soroban_sdk::Env,
    player: soroban_sdk::Address,
    wager: i128,
) -> Result

Get the timeout duration

fn get_timeout(env: soroban_sdk::Env) -> u64

Set the timeout duration

fn set_timeout(env: soroban_sdk::Env, timeout_seconds: u64)

Start a new match between two players (legacy - use find_match instead)

Both players must authorize with their wagers. This creates a session in Blendizzard and locks FP.

fn start_match(
    env: soroban_sdk::Env,
    session_id: u32,
    player1: soroban_sdk::Address,
    player2: soroban_sdk::Address,
    player1_wager: i128,
    player2_wager: i128,
) -> Result<(), soroban_sdk::Error>

Cancel queue - remove yourself from the matchmaking queue

fn cancel_queue(
    env: soroban_sdk::Env,
    player: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Initialize the contract with Blendizzard address and admin

fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    blendizzard: soroban_sdk::Address,
)

Claim victory by timeout if opponent hasn't acted

Can be called if the opponent hasn't committed or revealed within the timeout period.

fn claim_timeout(
    env: soroban_sdk::Env,
    session_id: u32,
    claimer: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Get the current Blendizzard contract address

fn get_blendizzard(env: soroban_sdk::Env) -> soroban_sdk::Address

Set a new Blendizzard contract address

fn set_blendizzard(env: soroban_sdk::Env, new_blendizzard: soroban_sdk::Address)

Get player's current active match session ID

fn get_player_match(env: soroban_sdk::Env, player: soroban_sdk::Address) -> Option

Clear the Blendizzard contract address (disables Blendizzard integration)

fn clear_blendizzard(env: soroban_sdk::Env)

Admin function to clear a stuck player match mapping Use this to fix players stuck in completed matches

fn clear_player_match(env: soroban_sdk::Env, player: soroban_sdk::Address)

Compute a commitment hash

This is a helper for the frontend to compute commitments. commitment = keccak256(choice || salt || session_id || round)

fn compute_commitment(
    env: soroban_sdk::Env,
    choice: u32,
    salt: soroban_sdk::BytesN<32>,
    session_id: u32,
    round: u32,
) -> soroban_sdk::BytesN<32>

Imports

WebAssembly Text (WAT) ▶