Contract b10d0e5874ca76bf27d01354972d854a93818d7a3e08cec006643e85cebf6693

← Back to Index 📥 Download WASM

Meta

rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.91.1

Instances

  • CAAQOZWQF6P22KPRPVUPCXSLV3I6GW44AD33HE5U3V3TRRMOGFC3CFXL
  • CC4JDKNSNQ4T6R74YVLWGHN4QRIF3JQILV5XRLQMYRD6GF5CAZ3BQHH6

Interface

Initialize the competition

  • admin: The backend oracle address that can submit scores
  • end_time: Unix timestamp when competition ends
  • token: Token contract address for prize pool (native XLM SAC address)
fn init(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    end_time: u64,
    token: soroban_sdk::Address,
)

Award prizes to top 10 players. Callable by anyone after end_time. Distribution: 1st=40%, 2nd=20%, 3rd=10%, 4th-10th=~4.3% each

fn payout(env: soroban_sdk::Env)

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

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 round (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
  • Resets finalized/paid_out flags
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

Imports

WebAssembly Text (WAT) ▶