Contract 48705b6cc769672cb7690fde75ab8b68a73525cba2c0ec4366d159dda2cdec16

← Back to Index 📥 Download WASM

Meta

cliver 25.2.0#
rssdkver 23.4.1#e671b396f8bacf1370925f722df158b31c0baae5
rsver 1.94.0

Instances

  • CBFC3YBTDCWPWR7Y4O73Q77TUBSXAYTGIV77CRJE2FL6GFV5FM6JG7TQ

Interface

Get a user's vote record for a round (None if not voted).

fn get_vote(
    env: soroban_sdk::Env,
    voter: soroban_sdk::Address,
    round_id: u32,
) -> Option
fn has_role(
    env: soroban_sdk::Env,
    account: soroban_sdk::Address,
    role: soroban_sdk::Symbol,
) -> Option

Cast a weighted vote directly — the voter signs this transaction.

Tier and weight are resolved via cross-contract call to the Reputation contract.

Returns

The vote weight applied

fn cast_vote(
    env: soroban_sdk::Env,
    voter: soroban_sdk::Address,
    round_id: u32,
    option_id: u32,
    vote_type: VoteType,
) -> u32
fn get_admin(env: soroban_sdk::Env) -> Option

Get a governance round by ID.

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

Add a redistribution option to an existing round.

Requires the "admin" role.

Returns

The newly assigned option_id

fn add_option(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    round_id: u32,
    title: soroban_sdk::String,
) -> u32

Get the admin role symbol.

fn admin_role(env: soroban_sdk::Env) -> soroban_sdk::Symbol

Get a governance option by round and option ID.

fn get_option(
    env: soroban_sdk::Env,
    round_id: u32,
    option_id: u32,
) -> Option
fn grant_role(
    env: soroban_sdk::Env,
    account: soroban_sdk::Address,
    role: soroban_sdk::Symbol,
    caller: soroban_sdk::Address,
)

Close a round and compute the winner.

Requires the "admin" role. Can only be called once end_ledger has been reached.

Returns

Winning option ID (None if no upvotes were cast)

fn close_round(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    round_id: u32,
) -> Option

Record a vote on behalf of a voter via the trusted recorder service.

Requires the "recorder" role.

This is the primary API integration path. Eligibility and tier are verified off-chain; the supplied tier is the authoritative vote weight source.

Arguments

  • caller - Recorder address (must have recorder role)
  • voter - Address of the voter
  • round_id - Active governance round ID
  • option_id - Option to vote for
  • vote_type - Up or Down
  • tier - Voter's NFT tier (verified off-chain by the API)

Returns

The vote weight applied

fn record_vote(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    voter: soroban_sdk::Address,
    round_id: u32,
    option_id: u32,
    vote_type: VoteType,
    tier: NftTier,
) -> u32
fn revoke_role(
    env: soroban_sdk::Env,
    account: soroban_sdk::Address,
    role: soroban_sdk::Symbol,
    caller: soroban_sdk::Address,
)

Create a new governance round.

Requires the "admin" role.

Arguments

  • caller - Admin address
  • title - Human-readable round title
  • start_ledger - Ledger sequence when voting opens
  • end_ledger - Ledger sequence when voting closes
  • fund_amount - Community fund at stake in stroops (0 if unset)

Returns

The newly assigned round_id

fn create_round(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    title: soroban_sdk::String,
    start_ledger: u32,
    end_ledger: u32,
    fund_amount: i128,
) -> u32

Initialize the Governance contract.

Arguments

  • admin - Address with admin privileges
  • reputation_contract - Address of the Reputation contract (for tier lookup)

Errors

  • Error::AlreadyInitialized - Contract was already initialized
fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    reputation_contract: soroban_sdk::Address,
)

Get the recorder role symbol.

fn recorder_role(env: soroban_sdk::Env) -> soroban_sdk::Symbol
fn renounce_role(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    caller: soroban_sdk::Address,
)
fn get_role_admin(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
) -> Option

Query a voter's NFT tier from the Reputation contract.

fn get_voter_tier(
    env: soroban_sdk::Env,
    voter: soroban_sdk::Address,
) -> Option
fn renounce_admin(env: soroban_sdk::Env)
fn set_role_admin(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    admin_role: soroban_sdk::Symbol,
)
fn get_role_member(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    index: u32,
) -> soroban_sdk::Address

Get the total number of voters in a round.

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

Get the live status of a round (automatically computes from current ledger).

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

Get the next round ID that would be assigned.

fn get_next_round_id(env: soroban_sdk::Env) -> u32

Get the next option ID that would be assigned for a round.

fn get_next_option_id(env: soroban_sdk::Env, round_id: u32) -> u32
fn transfer_admin_role(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
    live_until_ledger: u32,
)
fn accept_admin_transfer(env: soroban_sdk::Env)
fn get_role_member_count(env: soroban_sdk::Env, role: soroban_sdk::Symbol) -> u32

Get the configured Reputation contract address.

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

Update the Reputation contract address.

Only the contract admin can call this.

fn set_reputation_contract(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    reputation_contract: soroban_sdk::Address,
)

Imports

WebAssembly Text (WAT) ▶