Skip to main content

Setting up governance in your project

Governance as a library

  1. Add the following under the libs section in your chromia.yml file:

    libs:
    governance:
    registry: git@bitbucket.org:chromawallet/originals-governance.git
    path: rell/src/governance
    tagOrBranch: development
    insecure: true

    If you're using the Governance Starter Kit repository, you'll find this library already included in your chromia.yml file.

  2. Customize the parameters in your config.yml file as needed.

Common arguments

Utilize a reference (&common_args) to standardize settings across all modules.

Accounts configuration

Manage rate limiting for user accounts in the lib.ft4.core.accounts section:

lib.ft4.core.accounts:
rate_limit:
active: false
max_points: 10
recovery_time: 5000
points_at_account_creation: 1
  • active: This enables or disables rate limiting.
  • max_points: The maximum points allowed before rate limiting is triggered.
  • recovery_time: Set the time (in ms) for recovery.
  • points_at_account_creation: Initial points granted to a new account.

Administrative configuration

Define your administrative control in the lib.ft4.core.admin and lib.governance sections:

lib.ft4.core.admin:
admin_pubkey: `YOUR_ADMIN_PUBKEY`
  • admin_pubkey: The public key of your system administrator.

Authentication settings

Specify authorized operations in the lib.ft4.core.auth section:

lib.ft4.core.auth:
evm_signatures_authorized_operations:
- governance.citizens.register_citizen
  • evm_signatures_authorized_operations: This defines operations that require EVM signatures.

Governance parameters

Manage staking, citizen participation, and voting power through the governance module:

lib.governance:
admin_pubkey: `YOUR_ADMIN_PUBKEY`
admin_evm_wallet: `YOUR_ADMIN_EVM_WALLET`
economy_chain_brid: `ECONOMY_CHAIN_BRID`
required_staked_chr_in_eth: `REQUIRED_STAKED_CHR_IN_ETH`
required_staked_chr_in_bnb: `REQUIRED_STAKED_CHR_IN_BNB`
required_chr_balance: `REQUIRED_CHR_BALANCE`
required_staked_chr_balance: `REQUIRED_STAKED_CHR_BALANCE`
  • admin_evm_wallet: The EVM-compatible wallet for administration.
  • economy_chain_brid: The identifier for the economy chain.
  • required_staked_chr: The minimum CHR staking requirements.

Citizen participation rules

Define cooldown periods for various governance actions:

lib.governance.citizens:
citizen_cooldown_days_on_draft_proposal: 0
citizen_cooldown_days_on_proposal_rejection: 0
councilor_cooldown_days_on_veto: 30
min_draft_cooldown_days: 1
max_draft_cooldown_days: 365
min_rejection_cooldown_days: 1
max_rejection_cooldown_days: 365
min_veto_cooldown_days: 1
max_veto_cooldown_days: 365
  • Cooldown periods: Establish restrictions on re-engaging in governance activities.

Proposal & voting configuration

Set your proposal parameters and veto settings:

lib.governance.proposals:
proposal_configs:
option_item_limit: 10
max_duration: 2592000000000
min_duration: 3600000
  • option_item_limit: The maximum number of choices per proposal.
  • max/min_duration: Time limits for proposals.
lib.governance.votes:
veto_config:
veto_period: 100000
vetoable_duration: 500000
  • veto_period: This specifies the time period during which a veto can be initiated after a proposal is approved or an event occurs. During this time, veto-eligible entities can challenge the decision.
  • vetoable_duration: This defines the maximum duration for which a proposal or decision remains subject to being vetoed.

The veto configuration ensures balance by giving veto powers only a limited window while protecting decisions from being perpetually subject to veto threats.

  1. Install the governance Rell library in your project:

    chr install

After installing the Rell dependencies, you will find the library as a folder named governance placed under the lib directory.

Import governance into your project

Once the Rell dependencies are installed, access the governance library located in the lib folder, ready for use upon proper import. When you import the entire governance library, you may unintentionally expose numerous operations. Carefully consider whether you want to import each module.

To provide you with more control, the library is split into separate modules.

warning

Your project must also import the Ethereum interoperability framework (EIF) to enable cross-chain communication from EVM nodes to Postchain nodes based on event emissions.

Governance library modules

Below are the modules that compose the governance library. Familiarizing yourself with these will help you understand the operations available to users.

  • citizens: Manages user registrations, verifications, and roles within the governance system.
  • proposals: Facilitates the creation, review, and tracking of governance proposals.
  • votes: Enables secure voting mechanisms and tallies votes for proposals.
  • eif: Provides cross-chain communication between EVM nodes and Postchain nodes via event emissions.

To integrate certain governance functionalities into the main application module, you should include the following import statements in the main.rell file:

import lib.governance.citizens;
import lib.governance.proposals;
tip

The Chromia Governance EVM dapp has a comprehensive website that documents its API.