Contract 5902a2ea98fdfbff45995ac186f3cfaf62f4a0c0233f4bb813f4dcbf9fb054f8

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.11#34f7f53ae31e0fd02aab436a9872e79fa671ca02
rsver 1.95.0

Instances

  • CANOCMDY2N3AVEK4RRHJZHEYT4J7WDA4DMOI3OWEAJYLTVM5IDRMMP4U

Interface

Casts a vote for a specific option in an active poll.

Arguments

  • poll_id - ID of the poll.
  • voter - Address of the voter (must authorize).
  • option_id - Zero-indexed option ID being voted for.
fn vote(
    env: soroban_sdk::Env,
    poll_id: u64,
    voter: soroban_sdk::Address,
    option_id: u32,
) -> Result<(), soroban_sdk::Error>

Retrieves poll metadata by ID.

fn get_poll(env: soroban_sdk::Env, poll_id: u64) -> Result

Retrieves details of a vote cast by a voter.

fn get_vote(
    env: soroban_sdk::Env,
    poll_id: u64,
    voter: soroban_sdk::Address,
) -> Result

Checks if a voter has already cast a vote in a specific poll.

fn has_voted(env: soroban_sdk::Env, poll_id: u64, voter: soroban_sdk::Address) -> bool

Closes a poll manually before or after its end time. Only creator can close.

Arguments

  • poll_id - ID of the poll to close.
  • caller - Address of caller (must authorize and match poll creator).
fn close_poll(
    env: soroban_sdk::Env,
    poll_id: u64,
    caller: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Creates a new poll with a hashed question, number of options, and active timeframe.

Arguments

  • creator - Address of the poll creator (must authorize).
  • question_hash - 32-byte hash representing the poll question.
  • option_count - Number of voting options (must be between 2 and 100).
  • start_time - Unix timestamp when voting opens.
  • end_time - Unix timestamp when voting closes.
fn create_poll(
    env: soroban_sdk::Env,
    creator: soroban_sdk::Address,
    question_hash: soroban_sdk::BytesN<32>,
    option_count: u32,
    start_time: u64,
    end_time: u64,
) -> Result

Retrieves current vote tallies for all options in a poll.

fn get_results(
    env: soroban_sdk::Env,
    poll_id: u64,
) -> Result, soroban_sdk::Error>

Imports

WebAssembly Text (WAT) ▶