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
Set a new admin address
fn set_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
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
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>
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)
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>