Skip to main content

Setting up governance in your project

To build and run the Governance Tool on Chromia, you should set up the project and properly configure the blockchain to connect the frontend with the Rell backend for efficient data handling. Before proceeding, regarding libraries or the project settings file, we recommend reviewing the project settings file section once again.

Governance as a library

libs define external libraries used in your project. It specifies the library name, registry URL, path within the repository, optional branch or tag, RID, and insecure download verification option.

  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: production
    rid: x"7588E3738993B03C32A47BC3B45CE525C30AF4D8AC833BD3C171CEC63076265F"
    insecure: true
    note

    If you're using the Governance Starter Kit repository, you'll find this library already included in your chromia.yml file, along with common arguments and other libraries such as eif, ft4, and pagination.

  2. Customize the parameters in your config.yml file as shown below.

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.

Setting rate-limit points_at_account_creation means that a user can at most perform 1 operations per time unit. The recovery time for these points can be set using recovery_time property which defaults to 5000ms. We can also configure the max_points an account can have or disable rate limiting altogether by setting active to false.

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
  • 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.

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

  1. The install command (chr install) enables you to download and use third-party Rell libraries in your dapp:

    chr install

After installing the Rell dependencies, you will find the library as a folder named governance placed under the lib directory, along with other built-in libraries such as eif and ft4.

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.

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 Governance Tool for EVM has a comprehensive website that documents its API.