Casts a vote for a specific option in an active poll.
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.
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.
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>