Contract 61b3a195cffcaa12b74442b7392f3a08bc00427c84c96f04a75c576821befb7d

← Back to Index 📥 Download WASM

Meta

rssdkver 23.3.0#a35990025247146e24cb9e1deda063f17f3e441d
rsver 1.93.0-nightly

Instances

  • CBAEDMI2H4PAS7B5IJTMWQROUCDX37CKFK7R5HVAWVAD3MGBSGBLJSWP

Interface

Player draws another card ("hit"). If the player's hand value exceeds 21, they bust and lose immediately.

Arguments

  • session_id - The session ID of the game
  • player - Address of the player drawing a card
fn hit(
    env: soroban_sdk::Env,
    session_id: u32,
    player: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Player chooses to stick (end their turn with current hand). If both players have stuck, the game can be revealed.

Arguments

  • session_id - The session ID of the game
  • player - Address of the player sticking
fn stick(
    env: soroban_sdk::Env,
    session_id: u32,
    player: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

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 (includes hands and winner after game ends)
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 FP wagers. This creates a session in Blendizzard and locks FP before starting the game. Each player is dealt 2 cards to start.

CRITICAL: This method requires authorization from THIS contract (not players). Blendizzard 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_wager - FP amount player1 is wagering
  • player2_wager - FP amount player2 is wagering
fn start_game(
    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

Arguments

  • admin - Admin address (can upgrade contract)
  • blendizzard - Address of the Blendizzard contract
fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    blendizzard: soroban_sdk::Address,
)

Reveal the winner of the game and submit outcome to Blendizzard. Can only be called after both players have stuck. This calculates hand values, determines the winner (closest to 21), and handles draws by dealing new hands.

Arguments

  • session_id - The session ID of the game

Returns

  • Address - Address of the winning player
fn reveal_winner(
    env: soroban_sdk::Env,
    session_id: u32,
) -> Result

Get the current hand value for a player.

Arguments

  • session_id - The session ID of the game
  • player - Address of the player

Returns

  • u32 - The total value of the player's hand
fn get_hand_value(
    env: soroban_sdk::Env,
    session_id: u32,
    player: soroban_sdk::Address,
) -> Result

Get the current Blendizzard contract address

Returns

  • Address - The Blendizzard contract address
fn get_blendizzard(env: soroban_sdk::Env) -> soroban_sdk::Address

Set a new Blendizzard contract address

Arguments

  • new_blendizzard - The new Blendizzard contract address
fn set_blendizzard(env: soroban_sdk::Env, new_blendizzard: soroban_sdk::Address)

Imports

WebAssembly Text (WAT) ▶