Contract 83feef85dba5a6c1205daa685c66ebebdd6610c0057b1bac46dae8864cd2b113

← Back to Index 📥 Download WASM

Meta

Description Tansu
cliver 25.1.0#a048a57a75762458b487052e0021ea704a926bee
home_domain tansu.dev
rssdkver 26.0.0#e1bf74ba6c3ddb591593f5eb5dfb85458ff714c1
rsver 1.95.0
source_repo github:Consulting-Manao/tansu

Instances

  • CDXINK2T3P46M4LWK35FVIXXHJ2XHAS4FOVCGVPJ63YV5OVTM24IY5BI

Interface

Cast a vote on a proposal.

Allows a member to vote on a proposal. The vote can be either public or anonymous depending on the proposal configuration. For public votes, the choice and weight are visible. For anonymous votes, only the weight is visible, and the choice is encrypted.

Voting incurs a collateral which is repaid upon proposal execution. If the proposal is revoked, the collateral is not repaid as the voter engaged with a malicious proposal.

Arguments

  • env - The environment object
  • voter - The address of the voter
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal to vote on
  • vote - The vote data (public or anonymous)

Panics

  • If the voter has already voted
  • If the voting period has ended
  • If the proposal is not active anymore
  • If the proposal doesn't exist
  • If the voter's weight exceeds their maximum allowed weight
fn vote(
    env: soroban_sdk::Env,
    voter: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
    vote: Vote,
)

Verify vote commitment proof for anonymous voting.

Validates that the provided tallies and seeds match the vote commitments without revealing individual votes. This ensures the integrity of anonymous voting results.

The commitment is:

C = g^v * h^r (in additive notation: gv + hr),

where g, h are BLS12-381 generator points and v is the vote choice, r is the seed. Voting weight is introduced during the tallying phase.

Arguments

  • env - The environment object
  • project_key - The project key identifier
  • proposal - The proposal containing vote commitments
  • tallies - Decoded tally values [approve, reject, abstain] (scaled by weights)
  • seeds - Decoded seed values [approve, reject, abstain] (scaled by weights)

Returns

  • bool - True if all commitments match the provided tallies and seeds

Panics

  • If no anonymous voting configuration exists for the project
fn proof(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
    proposal: Proposal,
    tallies: soroban_sdk::Vec,
    seeds: soroban_sdk::Vec,
) -> bool

Execute a vote after the voting period ends.

Processes the voting results and determines the final status of the proposal. For public votes, the results are calculated directly from vote counts. For anonymous votes, tallies and seeds are validated against vote commitments to ensure the results are correct.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer executing the proposal
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal to execute
  • [Option<tallies>] - decoded tally values (scaled by weights), respectively Approve, reject and abstain
  • [Option<seeds>] - decoded seed values (scaled by weights), respectively Approve, reject and abstain

Returns

  • types::ProposalStatus - The final status of the proposal (Approved, Rejected, or Cancelled)

Panics

  • If the voting period hasn't ended
  • If the proposal doesn't exist
  • If the proposal is not active anymore
  • If tallies/seeds are missing for anonymous votes
  • If commitment
fn execute(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
    tallies: Option>,
    seeds: Option>,
) -> ProposalStatus

Returns a page of proposals (0 to MAX_PROPOSALS_PER_PAGE proposals per page).

Arguments

  • env - The environment object
  • project_key - The project key identifier
  • page - The page number (0-based)

Returns

  • types::Dao - The DAO object containing a page of proposals

Panics

  • If the page number is out of bounds
fn get_dao(env: soroban_sdk::Env, project_key: soroban_sdk::Bytes, page: u32) -> Dao

Remove a malicious or non-compliant vote from a proposal.

Only a project maintainer can call this. The voter's collateral is slashed (kept by the contract) as a penalty. The vote must be cast on an active proposal (removal is allowed even after the voting period ends).

Arguments

  • env - The environment object
  • maintainer - Address of the maintainer removing the vote
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal
  • voter - The address of the voter whose vote is being removed

Panics

  • If the maintainer is not authorized
  • If the proposal is not active
  • If no vote from the given voter exists
fn remove_vote(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
    voter: soroban_sdk::Address,
)

Get a single proposal by ID.

Arguments

  • env - The environment object
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal to retrieve

Returns

  • types::Proposal - The proposal object

Panics

  • If the proposal doesn't exist
fn get_proposal(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
) -> Proposal

Create a new proposal for a project.

The proposer is automatically added to the abstain group. By creating a proposal, the proposer incur a collateral which is repaid upon execution of the proposal unless the proposal is revoked. This is a deterrent mechanism.

Arguments

  • env - The environment object
  • proposer - Address of the proposal creator
  • project_key - Unique identifier for the project
  • title - Title of the proposal
  • ipfs - IPFS content identifier describing the proposal
  • voting_ends_at - UNIX timestamp when voting ends
  • public_voting - Whether voting is public or anonymous
  • [Option<token_contract>] - token contract for token-based voting
  • [Option<Vec<OutcomeContract>>] - outcome contracts executed after proposal completion

Returns

  • u32 - The ID of the created proposal.

Panics

  • If the title is too long
  • If the voting period is invalid
  • If the project doesn't exist
fn create_proposal(
    env: soroban_sdk::Env,
    proposer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    title: soroban_sdk::String,
    ipfs: soroban_sdk::String,
    voting_ends_at: u64,
    public_voting: bool,
    token_contract: Option,
    outcome_contracts: Option>,
) -> u32

Revoke a proposal.

Useful if there was some spam or bad intent. That will prevent the collateral to be claimed back.

Arguments

  • env - The environment object
  • maintainer - Address of the maintainer or admin revoking the proposal
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal to revoke

Panics

  • If the proposal is not active anymore
  • If the maintainer is not authorized
fn revoke_proposal(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
)

Setup anonymous voting for a project.

Configures BLS12-381 cryptographic primitives for anonymous voting.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer (must be authorized)
  • project_key - Unique identifier for the project
  • public_key - Asymmetric public key to be used for vote encryption

Panics

  • If the caller is not an authorized maintainer of the project
fn anonymous_voting_setup(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    public_key: soroban_sdk::String,
)

Add addresses to the conflict-of-interest list of a proposal.

Addresses on the list cannot cast a vote on the proposal.

Arguments

  • env - The environment object
  • maintainer - A maintainer of the project (must authenticate)
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal
  • addresses - Addresses to add to the list

Panics

  • If the maintainer is not authorized
  • If the proposal is not active anymore
fn add_conflict_of_interest(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
    addresses: soroban_sdk::Vec,
)

Get the conflict-of-interest list for a proposal.

Arguments

  • env - The environment object
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal

Returns

  • Vec<Address> - Addresses barred from voting on the proposal
fn get_conflict_of_interest(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
) -> soroban_sdk::Vec

Get the anonymous voting configuration for a project.

Arguments

  • env - The environment object
  • project_key - The project key identifier

Returns

  • types::AnonymousVoteConfig - The anonymous voting configuration

Panics

  • If no anonymous voting configuration exists for the project
fn get_anonymous_voting_config(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
) -> AnonymousVoteConfig

Remove addresses from the conflict-of-interest list of a proposal.

Arguments

  • env - The environment object
  • maintainer - A maintainer of the project (must authenticate)
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal
  • addresses - Addresses to remove from the list

Panics

  • If the maintainer is not authorized
  • If the proposal is not active anymore
fn remove_conflict_of_interest(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
    addresses: soroban_sdk::Vec,
)

Build vote commitments from votes and seeds for anonymous voting.

Creates BLS12-381 commitments for each vote using the formula: C = g·vote + h·seed where g and h are generator points on BLS12-381.

Note: This function does not consider voting weights, which are applied during the tallying phase. Calling this on the smart contract would reveal the votes and seeds, so it must be run either in simulation or client-side.

Arguments

  • env - The environment object
  • project_key - Unique identifier for the project
  • votes - Vector of vote choices (0=approve, 1=reject, 2=abstain)
  • seeds - Vector of random seeds for each vote

Returns

  • Vec<BytesN<96>> - Vector of vote commitments (one per vote)

Panics

  • If no anonymous voting configuration exists for the project
fn build_commitments_from_votes(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
    votes: soroban_sdk::Vec,
    seeds: soroban_sdk::Vec,
) -> soroban_sdk::Vec>

Pause or unpause the contract (emergency stop.)

Arguments

  • env - The environment object
  • admin - The admin address
  • paused - Pause or unpause the contract operations which change ledger states.
fn pause(env: soroban_sdk::Env, admin: soroban_sdk::Address, paused: bool)

Get the current version of the contract.

Returns

  • u32 - The contract version number
fn version(env: soroban_sdk::Env) -> u32

Initialize the Tansu contract with admin configuration.

Arguments

  • env - The environment object
  • admin - The admin address
fn __constructor(env: soroban_sdk::Env, admin: soroban_sdk::Address)

Approve an upgrade proposal

Arguments

  • env - The environment object
  • admin - An admin address

Panics

  • If the admin is not authorized
  • If the admin already approved
  • If there is no upgrade to approve
fn approve_upgrade(env: soroban_sdk::Env, admin: soroban_sdk::Address)

Propose a contract upgrade.

Arguments

  • env - The environment object
  • admin - An admin address
  • new_wasm_hash - The new WASM hash
  • new_admins_config - Optional new admin configuration (None to keep current)

Panics

  • If the admin is not authorized
  • If there is already an existing proposal (cancel the previous first)
fn propose_upgrade(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    new_wasm_hash: soroban_sdk::BytesN<32>,
    new_admins_config: Option,
)

Execute or cancel upgrade proposal

Arguments

  • env - The environment object
  • admin - An admin address
  • accept - true to accept and false to reject.

Upgrades can always be cancelled but only executed if there are enough approvals and the timelock period is over. Note that current governance rules apply. New config changes only in force after an update.

Panics

  • If the admin is not authorized
  • If it is too early to execute
  • If there are not enough approvals
  • If there is no upgrade to execute
fn finalize_upgrade(env: soroban_sdk::Env, admin: soroban_sdk::Address, accept: bool)

Set the Neural Quorum Governance contract.

Arguments

  • env - The environment object
  • admin - The admin address
  • nqg_contract - The new NQG contract
fn set_nqg_contract(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    nqg_contract: Contract,
    project: soroban_sdk::String,
)

Get current administrators configuration.

Arguments

  • env - The environment object

Returns

  • types::AdminsConfig - The administrators configuration
fn get_admins_config(env: soroban_sdk::Env) -> AdminsConfig

Require that the contract is not paused, panic if it is

Panics

  • If the contract is paused.
fn require_not_paused(env: soroban_sdk::Env)

Set the Soroban Domain contract.

Arguments

  • env - The environment object
  • admin - The admin address
  • domain_contract - The new domain contract
fn set_domain_contract(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    domain_contract: Contract,
)

Get upgrade proposal details

fn get_upgrade_proposal(env: soroban_sdk::Env) -> UpgradeProposal

Set the Collateral contract.

Arguments

  • env - The environment object
  • admin - The admin address
  • collateral_contract - The new collateral contract
fn set_collateral_contract(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    collateral_contract: Contract,
)
fn projects_migration(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    names: soroban_sdk::Vec,
)

Add a new member to the system with metadata.

Arguments

  • env - The environment object
  • member_address - The address of the member to add
  • meta - Metadata string associated with the member (e.g., IPFS hash)

Panics

  • If the member already exists
fn add_member(
    env: soroban_sdk::Env,
    member_address: soroban_sdk::Address,
    meta: soroban_sdk::String,
)

Get all badges for a specific project, organized by badge type.

Returns a structure containing vectors of member addresses for each badge type (Developer, Triage, Community, Verified).

Arguments

  • env - The environment object
  • key - The project key identifier

Returns

  • types::Badges - Structure containing member addresses for each badge type
fn get_badges(env: soroban_sdk::Env, key: soroban_sdk::Bytes) -> Badges

Get member information including all project badges.

Arguments

  • env - The environment object
  • member_address - The address of the member to retrieve

Returns

  • types::Member - Member information including metadata and project badges

Panics

  • If the member doesn't exist
fn get_member(env: soroban_sdk::Env, member_address: soroban_sdk::Address) -> Member

Set badges for a member in a specific project.

This function replaces all existing badges for the member in the specified project with the new badge list. The member's maximum voting weight is calculated as the sum of all assigned badge weights.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer (must be authorized)
  • key - The project key identifier
  • member - The address of the member to set badges for
  • badges - Vector of badges to assign

Panics

  • If the maintainer is not authorized
  • If the member doesn't exist
  • If the project doesn't exist
fn set_badges(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    key: soroban_sdk::Bytes,
    member: soroban_sdk::Address,
    badges: soroban_sdk::Vec,
)

Update the metadata of an existing member.

Arguments

  • env - The environment object
  • member_address - The address of the member to update
  • meta - New metadata string associated with the member (e.g., IPFS hash)

Panics

  • If the member doesn't exist
fn update_member(
    env: soroban_sdk::Env,
    member_address: soroban_sdk::Address,
    meta: soroban_sdk::String,
)

Get the maximum voting weight for an address in a specific project.

Calculates the sum of all badge weights for the address in the project. Returns the Default badge weight (1) if the address has no badges assigned or is not a registered member.

There is a special case to use Neural Quorum Governance instead of badges if we are using a specific project.

Arguments

  • env - The environment object
  • project_key - The project key identifier
  • member_address - The address to check

Returns

  • u32 - The maximum voting weight for the address
fn get_max_weight(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
    member_address: soroban_sdk::Address,
) -> u32

Set the latest commit hash for a project.

Updates the current commit hash for the specified project.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer calling this function
  • project_key - The project key identifier
  • hash - The new commit hash

Panics

  • If the project doesn't exist
  • If the maintainer is not authorized
fn commit(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    hash: soroban_sdk::String,
)

Register a new project.

Creates a new project entry with maintainers, URL, and commit hash. Also registers the project name in the domain contract if not already registered. The project key is generated using keccak256 hash of the project name.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer calling this function
  • name - The project name (max 15 characters)
  • maintainers - List of maintainer addresses for the project
  • url - The project's Git repository URL
  • ipfs - CID of the tansu.toml file with associated metadata

Returns

  • Bytes - The project key (keccak256 hash of the name)

Panics

  • If the project name is longer than 15 characters
  • If the project already exists
  • If the maintainer is not authorized
  • If the domain registration fails
  • If the maintainer doesn't own an existing domain
fn register(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    name: soroban_sdk::String,
    maintainers: soroban_sdk::Vec,
    url: soroban_sdk::String,
    ipfs: soroban_sdk::String,
) -> soroban_sdk::Bytes

Get the latest commit hash for a project.

Arguments

  • env - The environment object
  • project_key - The project key identifier

Returns

  • String - The current commit hash

Panics

  • If the project doesn't exist
fn get_commit(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
) -> soroban_sdk::String

Get project information including configuration and maintainers.

Arguments

  • env - The environment object
  • project_key - The project key identifier

Returns

  • types::Project - Project information including name, config, and maintainers

Panics

  • If the project doesn't exist
fn get_project(env: soroban_sdk::Env, project_key: soroban_sdk::Bytes) -> Project

Get a page of projects.

Arguments

  • env - The environment object
  • page - The page number (0-based)

Returns

  • Vec<types::Project> - List of projects on the requested page
fn get_projects(env: soroban_sdk::Env, page: u32) -> soroban_sdk::Vec

Update the configuration of an existing project.

Allows maintainers to change the project's URL, IPFS metadata, and maintainer list.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer calling this function
  • key - The project key identifier
  • maintainers - New list of maintainer addresses
  • url - New Git repository URL
  • ipfs - New CID of the tansu.toml file with metadata

Panics

  • If the project doesn't exist
  • If the maintainer is not authorized
fn update_config(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    key: soroban_sdk::Bytes,
    maintainers: soroban_sdk::Vec,
    url: soroban_sdk::String,
    ipfs: soroban_sdk::String,
)

Get sub-projects for a project (if it's an organization).

Arguments

  • env - The environment object
  • project_key - The project key identifier

Returns

  • Vec<Bytes> - List of sub-project keys, empty if not an organization
fn get_sub_projects(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
) -> soroban_sdk::Vec

Set sub-projects for a project (making it an organization).

Note: by design, sub-project keys are not validated against existing projects. This allows reserving a project space before the project is registered (since the key is derived from the name). A project can also appear in multiple organizations.

Arguments

  • env - The environment object
  • maintainer - The maintainer address calling this function
  • project_key - The project key identifier
  • sub_projects - List of sub-project keys to associate

Panics

  • If the project doesn't exist
  • If the maintainer is not authorized
  • If more than 10 sub-projects are provided
fn set_sub_projects(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    sub_projects: soroban_sdk::Vec,
)

Imports

WebAssembly Text (WAT) ▶