Contract 03f043bfa7abbc491852f1d0a90e6d6b8c13006774d54e38a12a062235fb0479

← Back to Index 📥 Download WASM

Meta

cliver 26.0.0#60f7458e7ecffddf2f2d91dc6d0d2db4fab03ecc
rssdkver 25.3.1#e50d95af029c83196dd122f0154bac3f1302394b
rsver 1.95.0

Interface

Read the configured admin (the account that funded the contract).

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

Submit a guess. The caller must first authorize a 0.1 XLM transfer to the contract as the cost of playing.

Returns:

  • Ok("correct") if the guess matches — the contract pays the 0.5 XLM reward to the guesser and rolls a new random number.
  • Ok("incorrect") if the guess does not match — the bet stays in the contract and the number is NOT rolled.

Errors (all state changes are rolled back atomically by Soroban):

  • Err(InvalidGuess) if the guess is outside 1..=5.
  • Err(FailedToTransferBet) if the 0.1 XLM bet could not be pulled from the guesser.
  • Err(InsufficientRewardFunds) if the contract cannot pay the full 0.5 XLM reward on a correct guess.
  • Err(FailedToTransferReward) if the reward transfer itself fails.
fn guess(
    env: soroban_sdk::Env,
    user_number: u64,
    guesser: soroban_sdk::Address,
) -> Result

Constructor.

admin funds the contract with INITIAL_FUNDING_XLM XLM out of its own balance (the deployer should fund the admin first). xlm is the address of the XLM Stellar Asset Contract on the target network — the deployer supplies it explicitly so the contract stays network-agnostic.

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

Imports

WebAssembly Text (WAT) ▶