Skip to main content

Setting up governance in your project

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

Governance as a library

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

  1. Add the following entries under the libs section in your chromia.yml file:
libs:
pagination:
registry: ssh://git@bitbucket.org:chromawallet/lib-pagination-utils.git
path: rell/src/core/pagination
tagOrBranch: master
insecure: true
ft4:
registry: https://gitlab.com/chromaway/ft4-lib.git
path: rell/src/lib/ft4
tagOrBranch: v1.0.0r
rid: x"FA487D75E63B6B58381F8D71E0700E69BEDEAD3A57D1E6C1A9ABB149FAC9E65F"
insecure: false
governance:
registry: git@bitbucket.org:chromawallet/originals-governance.git
path: rell/src/governance
tagOrBranch: production
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.

  1. 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:

blockchains:
<my_chain_name>:
module: <module_name>
moduleArgs:
lib.ft4.core.accounts:
rate_limit:
active: false
max_points: 10
recovery_time: 5000
points_at_account_creation: 1
  • active: Enables or disables rate limiting.
  • max_points: The maximum points allowed before rate limiting is triggered.
  • recovery_time: Sets the recovery time (in milliseconds).
  • points_at_account_creation: Initial points granted to a new account.

When setting points_at_account_creation for rate limiting, a user can perform at most one operation per time unit. The recovery time for these points can be set using the recovery_time property, which defaults to 5000 ms. Additionally, you can configure the max_points an account can reach, or disable rate limiting altogether by setting active to false.

Administrative configuration

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

blockchains:
<my_chain_name>:
module: <module_name>
moduleArgs:
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:

blockchains:
<my_chain_name>:
module: <module_name>
moduleArgs:
lib.ft4.core.auth:
evm_signatures_authorized_operations:
- governance.citizens.register_citizen
  • evm_signatures_authorized_operations: Defines operations that require EVM signatures.

Governance parameters

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

blockchains:
<my_chain_name>:
module: <module_name>
moduleArgs:
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:

blockchains:
<my_chain_name>:
module: <module_name>
moduleArgs:
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 and voting configuration

Set your proposal parameters and veto settings:

blockchains:
<my_chain_name>:
module: <module_name>
moduleArgs:
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_duration / min_duration: Time limits for proposals.
blockchains:
<my_chain_name>:
module: <module_name>
moduleArgs:
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, entities eligible to veto 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.

Installing dependencies

Use the install command (chr install) to download and use third-party Rell libraries in your dapp:

chr install

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

Importing 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 divided 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.
  • auth: Provides a way for centralized authentication server usage for registration, which is an optional feature.
  • proposals: Facilitates the creation, review, and tracking of governance proposals.
  • votes: Enables secure voting mechanisms and tallies votes for proposals.
  • Extensions: Extensions are optional modules that can be used to extend the functionality of the Governance Tool.
    • eif: Provides cross-chain communication between EVM nodes and Postchain nodes via event emissions. Required for EVM chain-based voting.
    • icmf: Manages the ICMF (Interchain Message Format) for cross-chain communication, useful for acquiring stake data from the Economy Chain.
    • delegates: Enables and manages delegates for the Governance Tool.

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

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