Contract 99defb40400ffb19ff29ac8eae40ea78f44a98dbf88ee6a62af0bb9c892828c9

← Back to Index 📥 Download WASM

Meta

cliver 23.2.1#e7dd9394b99a6064c489be50434a66d2349d9d35
rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.91.1

Instances

  • CD6TWMEI7JERQB45LDRCIP2WBVFNDEY2QAVQ2NW2G6IVIJOW3CRJJ4OB

Interface

Initialize the competition

  • admin: The backend oracle address that can submit scores
  • end_time: Unix timestamp when first epoch ends
  • token: Token contract address for prize pool (native XLM SAC address)
  • epoch_duration: Optional epoch duration in seconds (defaults to 3 days)
fn init(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    end_time: u64,
    token: soroban_sdk::Address,
    epoch_duration: Option,
)

Award entire prize pool to #1 player. Callable by anyone after end_time. Returns true if prize was distributed, false if no pool or no participants

fn payout(env: soroban_sdk::Env) -> bool

Upgrade the contract to a new WASM binary Can only be called by admin

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

Get competition state

fn get_state(env: soroban_sdk::Env) -> GameConfig

Update token address (admin only) Use this to fix misconfigured token address

fn set_token(env: soroban_sdk::Env, token: soroban_sdk::Address)

Get current leader (backwards compatible - returns top of leaderboard)

fn get_leader(env: soroban_sdk::Env) -> (soroban_sdk::Address, u64)

Submit a verified score (called by backend oracle) Only updates if it's a new personal best

fn submit_score(env: soroban_sdk::Env, player: soroban_sdk::Address, score: u64)

Emergency function to recover all funds Can ONLY be called by the hardcoded panic admin address Returns all XLM to the panic admin

fn panic_withdraw(env: soroban_sdk::Env)

Get the full leaderboard (top 10)

fn get_leaderboard(env: soroban_sdk::Env) -> soroban_sdk::Vec

Start a new epoch (admin only)

  • Archives current leaderboard to RoundHistory(current_round_id)
  • Archives current config to RoundConfig(current_round_id)
  • Clears current leaderboard
  • Increments round_id
  • Sets new end_time based on epoch_duration from now
  • Resets finalized/paid_out flags
fn start_new_epoch(env: soroban_sdk::Env)

Legacy function for backwards compatibility Now calls start_new_epoch internally

fn start_new_round(env: soroban_sdk::Env, _new_end_time: u64)

Get historical config for a specific completed round

fn get_round_config(env: soroban_sdk::Env, round_id: u32) -> Option

Get a player's personal best score

fn get_personal_best(env: soroban_sdk::Env, player: soroban_sdk::Address) -> u64

Get historical leaderboard for a specific completed round

fn get_round_history(
    env: soroban_sdk::Env,
    round_id: u32,
) -> soroban_sdk::Vec

Update epoch duration (admin only) Takes effect on the next epoch

fn set_epoch_duration(env: soroban_sdk::Env, duration_seconds: u64)

Imports

WebAssembly Text (WAT) ▶