Solana.SPL.Governance (Solana v0.1.0)

View Source

Functions for interacting with the SPL Governance program.

The governance program aims to provide core building blocks for creating Decentralized Autonomous Organizations (DAOs).

Summary

Functions

Generates the instructions to add a signatory to the proposal.

Generates the instructions to cancel the given proposal.

Generates the instructions for a token owner to cast a vote on the given proposal.

Generates instructions which create an Account Governance account, used to govern an arbitrary account.

Generates instructions which create an Mint Governance account, used to govern a token mint.

Generates instructions to create a native SOL treasury account for a Governance account.

Generates instructions to create a Token Owner Record with no voter weight (0 deposit).

Generates instructions which create an Program Governance account, used to govern an upgradable Solana program.

Generates instructions which create a Proposal account.

Generates instructions which create a new realm.

Generates instructions which create a Token Governance account, used to govern a token account.

Generates instructions which set the new governance delegate for an ownership account within the given realm and mint.

Generates instructions which deposit governing tokens -- community or council -- to the given realm.

Generates instructions to execute the instruction at index index in the proposal.

Generates instructions to finalize a vote.

Finds the account governance address for the given realm and account. Should have the seeds: ["account-governance", realm, account].

Finds a token holding address for the given community/council mint. Should have the seeds: ["governance", realm, mint].

Finds the program metadata address for the given governance program. Should have the seeds: ["metadata"]

Finds the mint governance address for the given realm and mint. Should have the seeds: ["mint-governance", realm, mint].

Finds the native SOL treasury address for the given governance account. Should have the seeds: ["treasury", governance]

Finds the token owner record address for the given realm, mint, and owner. Should have the seeds: ["governance", realm, mint, owner].

Finds the program governance address for the given realm and governed program. Should have the seeds: ["program-governance", realm, governed].

Finds the governance proposal address for the given mint and index. Should have the seeds: ["governance", governance, mint, index].

Finds the realm address for the given name. Should have the seeds ["governance", name]

Finds the realm config address for the given realm. Should have the seeds: ["realm-config", realm].

Finds the proposal's signatory record address. Should have the seeds: ["governance", proposal, signatory].

Finds the token governance address for the given realm and token. Should have the seeds: ["token-governance", realm, token].

Finds the proposal's transaction address for the given option and index. Should have the seeds: ["governance", proposal, option, index].

Finds the vote record address for the given proposal and owner_record. Should have the seeds: ["governance", proposal, owner_record].

Flag an instruction and its parent proposal with "error" status.

The Governance program's default instance ID. Organizations can also deploy their own custom instance if they wish.

Generates the instructions to insert a transaction into the proposal at the given index.

Generates instructions to relinquish a voter's vote from a proposal.

Generates the instructions to remove a signatory from the proposal.

Generates the instructions to remove the Transaction data at the given index from the given proposal.

Generates the instructions to set a governance's config.

Generates the instructions to set a new realm authority.

Generates instructions to set the realm config.

Generates the instructions for a signatory to sign off on a proposal.

The governance program's test instance ID. This can be used to set up test DAOs.

Generates instructions to update a Program Metadata account.

Generates instructions which withdraw governing tokens -- community or council -- from the given realm.

Functions

add_signatory(opts)

Generates the instructions to add a signatory to the proposal.

This means that the proposal can't leave Draft state until this signatory signs off on it.

Options

  • :proposal - Required. proposal account to add the signatory to.

  • :signatory - Required. the signatory to add to the proposal.

  • :authority - Required. Public key of the governance authority (or its delegate).

  • :payer - Required. The account which will pay for the new signatory record's creation.

  • :owner_record - Required. Public key of the proposal owner's Token Owner Record account.

  • :program - Required. Public key of the governance program instance to use.

cancel_proposal(opts)

Generates the instructions to cancel the given proposal.

Options

  • :governance - Required. The governance account.

  • :proposal - Required. The proposal account.

  • :owner_record - Required. Public key of the proposal owner's Token Owner Record account.

  • :authority - Required. Public key of the governance authority (or its delegate).

  • :program - Required. Public key of the governance program instance to use.

cast_vote(opts)

Generates the instructions for a token owner to cast a vote on the given proposal.

By doing so, the owner indicates they approve or disapprove of running the proposal's set of instructions.

If this vote causes the proposal to reach a consensus, the instructions can be run after the configured delay.

Options

  • :realm - Required. The realm account.

  • :proposal - Required. The proposal account.

  • :governance - Required. The governance account.

  • :owner_record - Required. Public key of the proposal owner's Token Owner Record account.

  • :authority - Required. Public key of the governance authority (or its delegate).

  • :mint - Required. The governing token mint.

  • :payer - Required. The account which will pay for the Vote Record account's creation.

  • :voter_weight_record - Public key of the voter weight record account.

  • :max_voter_weight_record - Public key of the max voter weight record account.

  • :voter - Required. Public key of the voter's governing token account.

  • :vote - Required. The user's vote. Passing an empty list indicates proposal rejection.

  • :program - Required. Public key of the governance program instance to use.

create_account_governance(opts)

Generates instructions which create an Account Governance account, used to govern an arbitrary account.

Options

  • :payer - Required. The account which will pay for the new Account Governance account's creation.

  • :owner_record - Required. The address of the governing Token Owner Record.

  • :authority - Required. Public key of the governance authority.

  • :realm - Required. Public key of the realm the created Governance belongs to.

  • :governed - Required. The account which will be goverened by the newly created governance.

  • :program - Required. Public key of the governance program instance to use.

  • :voter_weight_record - Public key of the voter weight record account.

  • :max_voter_weight_record - Public key of the max voter weight record account.

  • :config - Required. The desired governance configuration.

    Options

    • :threshold - Required. The type of vote threshold used to resolve a Proposal vote.

    • :vote_weight_source - The source of vote weight for voters. The default value is :deposit.

    • :minimum_community (non_neg_integer/0) - The minimum number of community tokens an owner must have to create a proposal. The default value is 1.

    • :minimum_council (non_neg_integer/0) - The minimum number of council tokens an owner must have to create a proposal. The default value is 1.

    • :duration (non_neg_integer/0) - Required. Time limit (in seconds) for a proposal to be open for voting.

    • :cooldown (non_neg_integer/0) - The time period (in seconds) within which a proposal can still be cancelled after voting has ended. The default value is 0.

    • :delay (non_neg_integer/0) - Minimum wait time (in seconds) after a proposal has been voted on before an instruction can be executed. The default value is 0.

create_mint_governance(opts)

Generates instructions which create an Mint Governance account, used to govern a token mint.

Options

  • :payer - Required. The account which will pay for the new Mint Governance account's creation.

  • :owner_record - Required. The address of the governing Token Owner Record.

  • :authority - Required. Public key of the governance authority.

  • :realm - Required. Public key of the realm the created Governance belongs to.

  • :governed - Required. The mint which will be goverened by the newly created governance.

  • :mint_authority - Required. The current mint authority of the mint to be governed.

  • :program - Required. Public key of the governance program instance to use.

  • :voter_weight_record - Public key of the voter weight record account.

  • :max_voter_weight_record - Public key of the max voter weight record account.

  • :config - Required. The desired governance configuration.

    Options

    • :threshold - Required. The type of vote threshold used to resolve a Proposal vote.

    • :vote_weight_source - The source of vote weight for voters. The default value is :deposit.

    • :minimum_community (non_neg_integer/0) - The minimum number of community tokens an owner must have to create a proposal. The default value is 1.

    • :minimum_council (non_neg_integer/0) - The minimum number of council tokens an owner must have to create a proposal. The default value is 1.

    • :duration (non_neg_integer/0) - Required. Time limit (in seconds) for a proposal to be open for voting.

    • :cooldown (non_neg_integer/0) - The time period (in seconds) within which a proposal can still be cancelled after voting has ended. The default value is 0.

    • :delay (non_neg_integer/0) - Minimum wait time (in seconds) after a proposal has been voted on before an instruction can be executed. The default value is 0.

  • :transfer_mint_authority? (boolean/0) - Whether or not the governed mint's authority should be transferred to the governance PDA. This can also be done later. The default value is false.

create_native_treasury(opts)

Generates instructions to create a native SOL treasury account for a Governance account.

The account has no data and can be used:

  • as a payer for instructions signed by governance PDAs
  • as a native SOL treasury

Options

  • :governance - Required. The governance account associated with the new treasury account.

  • :payer - Required. The account which will pay for the native treasury account's creation.

  • :program - Required. Public key of the governance program instance to use.

create_owner_record(opts)

Generates instructions to create a Token Owner Record with no voter weight (0 deposit).

This is used to register a token owner when the Voter Weight Add-in is used and the Governance program doesn't take deposits.

Options

  • :realm - Required. The realm account.

  • :owner - Required. The governing token owner's account.

  • :mint - Required. The mint for the governing token.

  • :payer - Required. The account which will pay for the Token Owner Record account's creation.

  • :program - Required. Public key of the governance program instance to use.

create_program_governance(opts)

Generates instructions which create an Program Governance account, used to govern an upgradable Solana program.

Options

  • :payer - Required. The account which will pay for the new Program Governance account's creation.

  • :owner_record - Required. The address of the governing Token Owner Record.

  • :authority - Required. Public key of the governance authority.

  • :realm - Required. Public key of the realm the created Governance belongs to.

  • :governed - Required. The program which will be goverened by the newly created governance.

  • :upgrade_authority - Required. The current upgrade authority of the goverened program.

  • :program - Required. Public key of the governance program instance to use.

  • :voter_weight_record - Public key of the voter weight record account.

  • :max_voter_weight_record - Public key of the max voter weight record account.

  • :transfer_upgrade_authority? (boolean/0) - Whether or not the governed program's upgrade authority should be transferred to the governance PDA. This can also be done later. The default value is false.

  • :config - Required. The desired governance configuration.

    Options

    • :threshold - Required. The type of vote threshold used to resolve a Proposal vote.

    • :vote_weight_source - The source of vote weight for voters. The default value is :deposit.

    • :minimum_community (non_neg_integer/0) - The minimum number of community tokens an owner must have to create a proposal. The default value is 1.

    • :minimum_council (non_neg_integer/0) - The minimum number of council tokens an owner must have to create a proposal. The default value is 1.

    • :duration (non_neg_integer/0) - Required. Time limit (in seconds) for a proposal to be open for voting.

    • :cooldown (non_neg_integer/0) - The time period (in seconds) within which a proposal can still be cancelled after voting has ended. The default value is 0.

    • :delay (non_neg_integer/0) - Minimum wait time (in seconds) after a proposal has been voted on before an instruction can be executed. The default value is 0.

create_proposal(opts)

Generates instructions which create a Proposal account.

Proposals allow governance token owners to propose governance changes (i.e. instructions) to an account that will go into effect (i.e. be executed) at some point in the future.

Options

  • :payer - Required. The account which will pay for the new Proposal account's creation.

  • :owner - Required. Public key of the token owner who is making the propsal.

  • :authority - Required. Public key of the governance authority.

  • :mint - Required. The governing token mint.

  • :governance - Required. The governance account for which this proposal is made.

  • :realm - Required. Public key of the realm the created Governance belongs to.

  • :program - Required. Public key of the governance program instance to use.

  • :voter_weight_record - Public key of the voter weight record account.

  • :max_voter_weight_record - Public key of the max voter weight record account.

  • :name (String.t/0) - Required. The proposal name.

  • :description (String.t/0) - Required. The proposal explanation.

  • :vote_type - Required. The proposal's vote type.

  • :options (list of String.t/0) - Required. Proposal options.

  • :has_deny_option? (boolean/0) - Indicates whether this proposal has a 'deny' option. Must be true if the proposal wants to include executable instructions. The default value is true.

  • :index (non_neg_integer/0) - Required. The proposal index, i.e. this is the Nth proposal for this governance.

create_realm(opts)

Generates instructions which create a new realm.

Options

  • :payer - Required. The account which will pay for the new realm account's creation.

  • :authority - Required. Public key of the authority account for the new realm.

  • :community_mint - Required. Community token mint for the new realm.

  • :council_mint - Community token mint for the new realm.

  • :program - Required. Public key of the governance program instance to use.

  • :voter_weight_addin - Community voter weight add-in program ID.

  • :max_voter_weight_addin - Max Community voter weight add-in program ID.

  • :name (String.t/0) - Required. The name of the new realm.

  • :max_vote_weight_source - Required. The source of max vote weight used for voting. Values below 100% mint supply can be used when the governing token is fully minted but not distributed yet.

  • :minimum (non_neg_integer/0) - Required. Minimum number of community tokens a user must hold to create a governance.

create_token_governance(opts)

Generates instructions which create a Token Governance account, used to govern a token account.

Options

  • :payer - Required. The account which will pay for the new Token Governance account's creation.

  • :owner_record - Required. The address of the governing Token Owner Record.

  • :authority - Required. Public key of the governance authority.

  • :realm - Required. Public key of the realm the created Governance belongs to.

  • :governed - Required. The account which will be goverened by the newly created governance.

  • :owner - Required. The current owner of the goverened token account.

  • :program - Required. Public key of the governance program instance to use.

  • :voter_weight_record - Public key of the voter weight record account.

  • :max_voter_weight_record - Public key of the max voter weight record account.

  • :config - Required. The desired governance configuration.

    Options

    • :threshold - Required. The type of vote threshold used to resolve a Proposal vote.

    • :vote_weight_source - The source of vote weight for voters. The default value is :deposit.

    • :minimum_community (non_neg_integer/0) - The minimum number of community tokens an owner must have to create a proposal. The default value is 1.

    • :minimum_council (non_neg_integer/0) - The minimum number of council tokens an owner must have to create a proposal. The default value is 1.

    • :duration (non_neg_integer/0) - Required. Time limit (in seconds) for a proposal to be open for voting.

    • :cooldown (non_neg_integer/0) - The time period (in seconds) within which a proposal can still be cancelled after voting has ended. The default value is 0.

    • :delay (non_neg_integer/0) - Minimum wait time (in seconds) after a proposal has been voted on before an instruction can be executed. The default value is 0.

  • :transfer_ownership? (boolean/0) - Whether or not the governed token's ownership should be transferred to the governance PDA. This can also be done later. The default value is false.

delegate(opts)

Generates instructions which set the new governance delegate for an ownership account within the given realm and mint.

The delegate can vote or create Proposals on behalf of the owner.

Note: Delegating voting rights doesn't take them away from the original owner.

Options

  • :owner - Required. The current non-delegated holder of voting rights within the realm.

  • :record - Required. The Token Owner Record account for which the owner wishes to delegate rights.

  • :to - The account which will receive voter rights from the owner in the given realm. Not including this argument will rescind the current delegate's voting rights.

  • :program - Required. Public key of the governance program instance to use.

deposit(opts)

Generates instructions which deposit governing tokens -- community or council -- to the given realm.

This establishes a user's voter weight to be used when voting within the realm.

Note: If a subsequent (top up) deposit is made, the user's vote weights on active proposals won't be updated automatically. To do this, the user must relinquish their votes and vote again.

Options

  • :owner - Required. The from token account's owner.

  • :authority - Required. The from token account's transfer authority.

  • :realm - Required. Public key of the realm to deposit user tokens into.

  • :mint - Required. The mint for the token the user wishes to deposit.

  • :from - Required. The user's token account.

  • :payer - Required. The account which will pay to create the user's token owner record account (if necessary).

  • :amount (pos_integer/0) - Required. The number of tokens to transfer.

  • :program - Required. Public key of the governance program instance to use.

execute_instruction(opts)

Generates instructions to execute the instruction at index index in the proposal.

Anybody can execute an instruction once the Proposal has been approved and the instruction's delay time has passed.

The instruction being executed will be signed by the Governance PDA the proposal belongs to, e.g. the Program Governance PDA for program upgrade instructions.

Options

  • :proposal - Required. The proposal account.

  • :instruction - Required. The Proposal Instruction account containing the instruction to execute.

  • :accounts - Any extra accounts that are part of the instruction, in order.

  • :program - Required. Public key of the governance program instance to use.

finalize_vote(opts)

Generates instructions to finalize a vote.

This is available in case the vote was not automatically tipped with the proposal's duration.

Options

  • :realm - Required. The realm account.

  • :proposal - Required. The proposal account.

  • :governance - Required. The governance account.

  • :owner_record - Required. Public key of the proposal owner's Token Owner Record account.

  • :mint - Required. The governing token mint.

  • :program - Required. Public key of the governance program instance to use.

find_account_governance_address(program, realm, account)

@spec find_account_governance_address(
  program :: Solana.Key.t(),
  realm :: Solana.Key.t(),
  account :: Solana.Key.t()
) :: {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the account governance address for the given realm and account. Should have the seeds: ["account-governance", realm, account].

find_holding_address(program, realm, mint)

@spec find_holding_address(
  program :: Solana.Key.t(),
  realm :: Solana.Key.t(),
  mint :: Solana.Key.t()
) ::
  {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds a token holding address for the given community/council mint. Should have the seeds: ["governance", realm, mint].

find_metadata_address(program)

@spec find_metadata_address(program :: Solana.Key.t()) ::
  {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the program metadata address for the given governance program. Should have the seeds: ["metadata"]

find_mint_governance_address(program, realm, mint)

@spec find_mint_governance_address(
  program :: Solana.Key.t(),
  realm :: Solana.Key.t(),
  mint :: Solana.Key.t()
) :: {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the mint governance address for the given realm and mint. Should have the seeds: ["mint-governance", realm, mint].

find_native_treasury_address(program, governance)

@spec find_native_treasury_address(
  program :: Solana.Key.t(),
  governance :: Solana.Key.t()
) ::
  {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the native SOL treasury address for the given governance account. Should have the seeds: ["treasury", governance]

find_owner_record_address(program, realm, mint, owner)

@spec find_owner_record_address(
  program :: Solana.Key.t(),
  realm :: Solana.Key.t(),
  mint :: Solana.Key.t(),
  owner :: Solana.Key.t()
) :: {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the token owner record address for the given realm, mint, and owner. Should have the seeds: ["governance", realm, mint, owner].

find_program_governance_address(program, realm, governed)

@spec find_program_governance_address(
  program :: Solana.Key.t(),
  realm :: Solana.Key.t(),
  governed :: Solana.Key.t()
) :: {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the program governance address for the given realm and governed program. Should have the seeds: ["program-governance", realm, governed].

find_proposal_address(program, governance, mint, index)

@spec find_proposal_address(
  program :: Solana.Key.t(),
  governance :: Solana.Key.t(),
  mint :: Solana.Key.t(),
  index :: integer()
) :: {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the governance proposal address for the given mint and index. Should have the seeds: ["governance", governance, mint, index].

find_realm_address(program, name)

@spec find_realm_address(program :: Solana.Key.t(), name :: String.t()) ::
  {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the realm address for the given name. Should have the seeds ["governance", name]

find_realm_config_address(program, realm)

@spec find_realm_config_address(program :: Solana.Key.t(), realm :: Solana.Key.t()) ::
  {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the realm config address for the given realm. Should have the seeds: ["realm-config", realm].

find_signatory_record_address(program, proposal, signatory)

@spec find_signatory_record_address(
  program :: Solana.Key.t(),
  proposal :: Solana.Key.t(),
  signatory :: Solana.Key.t()
) :: {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the proposal's signatory record address. Should have the seeds: ["governance", proposal, signatory].

find_token_governance_address(program, realm, token)

@spec find_token_governance_address(
  program :: Solana.Key.t(),
  realm :: Solana.Key.t(),
  token :: Solana.Key.t()
) :: {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the token governance address for the given realm and token. Should have the seeds: ["token-governance", realm, token].

find_transaction_address(program, proposal, index, option \\ 0)

@spec find_transaction_address(
  program :: Solana.Key.t(),
  proposal :: Solana.Key.t(),
  index :: non_neg_integer(),
  option :: non_neg_integer()
) :: {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the proposal's transaction address for the given option and index. Should have the seeds: ["governance", proposal, option, index].

find_vote_record_address(program, proposal, owner_record)

@spec find_vote_record_address(
  program :: Solana.Key.t(),
  proposal :: Solana.Key.t(),
  owner_record :: Solana.Key.t()
) :: {:ok, Solana.Key.t()} | {:error, :no_nonce}

Finds the vote record address for the given proposal and owner_record. Should have the seeds: ["governance", proposal, owner_record].

flag_instruction_error(opts)

Flag an instruction and its parent proposal with "error" status.

Options

  • :proposal - Required. The proposal account.

  • :instruction - Required. The Proposal Instruction account to flag.

  • :authority - Required. Public key of the governance authority (or its delegate).

  • :owner_record - Required. Public key of the proposal owner's Token Owner Record account.

  • :program - Required. Public key of the governance program instance to use.

id()

The Governance program's default instance ID. Organizations can also deploy their own custom instance if they wish.

insert_transaction(opts)

Generates the instructions to insert a transaction into the proposal at the given index.

New transactions must be inserted at the end of the range indicated by the proposal's transaction_next_index property. If a transaction replaces an existing transaction at a given index, the old one must first be removed by calling Solana.SPL.Governance.remove_transaction/1.

Options

  • :governance - Required. The governance account.

  • :proposal - Required. The proposal account.

  • :owner_record - Required. Public key of the proposal owner's Token Owner Record account.

  • :authority - Required. Public key of the governance authority (or its delegate).

  • :payer - Required. The account which will pay for the Proposal Instruction account's creation.

  • :option (non_neg_integer/0) - The index of the option the instruction is for. The default value is 0.

  • :index (non_neg_integer/0) - Required. The index where the instruction will be inserted.

  • :delay (non_neg_integer/0) - Wait time (in seconds) between the vote period ending and the instruction being eligible for execution. The default value is 0.

  • :instructions - Required. Data for the instructions to be executed

  • :program - Required. Public key of the governance program instance to use.

relinquish_vote(opts)

Generates instructions to relinquish a voter's vote from a proposal.

If the proposal is still being voted on, the voter's weight won't count toward the outcome. If the proposal is already decided, this instruction has no effect on the proposal, but allows voters to prune their outstanding votes in case they want to withdraw governing tokens from the realm.

Options

  • :proposal - Required. The proposal account.

  • :governance - Required. The governance account.

  • :owner_record - Required. Public key of the voter's governing Token Owner Record.

  • :mint - Required. The governing token mint.

  • :authority - Public key of the governance authority (or its delegate). Only required if the proposal is still being voted on.

  • :beneficiary - Public key of the account to receive the disposed vote record account's lamports. Only required if the proposal is still being voted on.

  • :program - Required. Public key of the governance program instance to use.

remove_signatory(opts)

Generates the instructions to remove a signatory from the proposal.

Options

  • :proposal - Required. proposal account to add the signatory to.

  • :signatory - Required. the signatory to add to the proposal.

  • :authority - Required. Public key of the governance authority (or its delegate).

  • :owner_record - Required. Public key of the proposal owner's Token Owner Record account.

  • :beneficiary - Required. Public key of the account to receive the disposed signatory record account's lamports.

  • :program - Required. Public key of the governance program instance to use.

remove_transaction(opts)

Generates the instructions to remove the Transaction data at the given index from the given proposal.

Options

  • :proposal - Required. The proposal account.

  • :owner_record - Required. Public key of the proposal owner's Token Owner Record account.

  • :authority - Required. Public key of the governance authority (or its delegate).

  • :beneficiary - Required. Public key of the account to receive the disposed instruction account's lamports.

  • :transaction - Required. The Proposal Transaction account indicating the transaction to remove.

  • :program - Required. Public key of the governance program instance to use.

set_governance_config(opts)

Generates the instructions to set a governance's config.

Options

  • :realm - Required. The realm account the governance belongs to.

  • :governance - Required. The governance account to receive the new config.

  • :config - Required. The desired governance configuration.

    Options

    • :threshold - Required. The type of vote threshold used to resolve a Proposal vote.

    • :vote_weight_source - The source of vote weight for voters. The default value is :deposit.

    • :minimum_community (non_neg_integer/0) - The minimum number of community tokens an owner must have to create a proposal. The default value is 1.

    • :minimum_council (non_neg_integer/0) - The minimum number of council tokens an owner must have to create a proposal. The default value is 1.

    • :duration (non_neg_integer/0) - Required. Time limit (in seconds) for a proposal to be open for voting.

    • :cooldown (non_neg_integer/0) - The time period (in seconds) within which a proposal can still be cancelled after voting has ended. The default value is 0.

    • :delay (non_neg_integer/0) - Minimum wait time (in seconds) after a proposal has been voted on before an instruction can be executed. The default value is 0.

  • :program - Required. Public key of the governance program instance to use.

set_realm_authority(opts)

Generates the instructions to set a new realm authority.

Options

  • :realm - Required. The realm account to assign a new authority.

  • :current - Required. The current realm authority.

  • :new - The new realm authority. Must be one of the realm governances.

  • :program - Required. Public key of the governance program instance to use.

  • :action - Required. The action to apply to the current realm authority. :set sets the new realm authority without checks, :set_checked makes sure the new authority is one of the realm's governances, and :remove removes the realm authority.

set_realm_config(opts)

Generates instructions to set the realm config.

Options

  • :realm - Required. The realm account.

  • :authority - Required. The realm authority.

  • :council_mint - The realm's council token mint.

  • :payer - The account which will pay for the Realm Config account's creation.

  • :voter_weight_addin - Community voter weight add-in program ID.

  • :max_voter_weight_addin - Max Community voter weight add-in program ID.

  • :program - Required. Public key of the governance program instance to use.

  • :max_vote_weight_source - Required. The source of max vote weight used for voting. Values below 100% mint supply can be used when the governing token is fully minted but not distributed yet.

  • :minimum (non_neg_integer/0) - Required. Minimum number of community tokens a user must hold to create a governance.

sign_off_proposal(opts)

Generates the instructions for a signatory to sign off on a proposal.

This indicates the signatory approves of the proposal. When the last signatory signs off, the proposal moves to the Voting state.

Options

  • :proposal - Required. The proposal account.

  • :signatory - Required. the signatory signing off on the proposal.

  • :program - Required. Public key of the governance program instance to use.

test_id()

The governance program's test instance ID. This can be used to set up test DAOs.

update_program_metadata(opts)

Generates instructions to update a Program Metadata account.

This dumps information implied by the governance program's code into a persistent account.

Options

  • :payer - Required. The account which will pay for the Program Metadata account's creation.

  • :program - Required. Public key of the governance program instance to use.

withdraw(opts)

Generates instructions which withdraw governing tokens -- community or council -- from the given realm.

This downgrades a user's voter weight within the realm.

Note: It's only possible to withdraw tokens if the user doesn't have any outstanding active votes. Otherwise, the user needs to relinquish those votes before withdrawing their tokens.

Options

  • :owner - Required. The to token account's owner.

  • :realm - Required. Public key of the realm to withdraw governance tokens from.

  • :mint - Required. The mint for the token the user wishes to withdraw.

  • :to - Required. The user's token account. All tokens will be transferred to this account.

  • :program - Required. Public key of the governance program instance to use.