Governance Tool EIF extension
The Governance Tool EIF extension enables synchronization with EVM events and handles them within the dapp. It uses Ethereum Interoperability Framework (EIF) to sync with EVM events.
How to use
To use the EIF extension, you need to import the lib.governance.extensions.eif
module into your dapp.
import lib.governance.extensions.eif;
Also, you need to add the Ethereum Interoperability Framework module and library to your dapp in the chromia.yml
file.
# chromia.yml
blockchains:
your_dapp_name:
module: main # Your main module file name
config:
features:
merkle_hash_version: 2
gtx:
modules:
- "net.postchain.eif.EifGTXModule"
sync_ext:
- "net.postchain.eif.EifSynchronizationInfrastructureExtension"
eif:
snapshot:
version: 2
chains:
ethereum: # Your EVM chain name (bsc, ethereum, sepolia, tac_turin, soon more)
network_id: 1 # Network ID of the EVM chain
contracts_to_fetch: # Any number of contracts to fetch
- address: "0x8a2279d4a90b6fe1c4b30fa660cc9f926797baa2" # Your contract address
skip_to_height: 17024400 # Skip to the height of the contract
- address: "0xC7b0F970c1EFBB181194Fc15ccD5C4a2c2Ab863B" # Your contract address
skip_to_height: 17024400 # Skip to the height of the contract
evm_read_offset: 3 # EVM read offset doesn't need to change it
read_offset: 2 # Read offset doesn't need to change.
events: !include ./config/events.yaml # Events to fetch include the events you want to fetch from the contracts
libs:
icmf:
registry: https://gitlab.com/chromaway/core/directory-chain
path: src/lib/icmf
tagOrBranch: 1.82.4
rid: x"1A4B3C3A1325DEF2C426C4F0F93F7444BB074373A24367DAA958C32F21B2EA1D"
insecure: false
eif:
registry: https://gitlab.com/chromaway/postchain-eif
path: postchain-eif-rell/rell/src/eif
tagOrBranch: 0.13.1
rid: x"AB40EDB0B534726B5F3AA288A5D31BE840B24BA670775E4F95C1B2512F5B8F22"
insecure: false
eif_event_receiver:
registry: https://gitlab.com/chromaway/postchain-eif
path: postchain-eif-rell/rell/src/eif_event_receiver
tagOrBranch: 0.13.1
rid: x"B20700DA8FE4FC7E5880BCCCB6FBE0B6A22CD6FAB61CDF9CE20E06B62D4902F4"
insecure: false
That is all you need to do to activate the EIF extension.
Custom modules
There are some custom modules inside the EIF extension that you can use to extend the functionality of the EIF extension. Furthermore, you can obtain a reference to build your own custom modules.
There are three custom modules inside the EIF extension:
lib.governance.extensions.eif.erc20_chr
lib.governance.extensions.eif.vote_power_strategies
lib.governance.extensions.eif.vote_requirements
erc20_chr.rell
This custom module is used to integrate full EVM CHR token support. It includes:
- ETH, BSC, SEPOLIA, BSC_TESTNET balance and stake tracking
- Automatic EVM token registration into the database
- Extended can_register that can check users total evm CHR balance or stake or both in the specified evm chains from eif configuration in chromia.yml
This is what should be added to chromia.yml to use this module additionally to the EIF extension:
# chromia.yml
blockchains:
your_dapp_name:
module: main # Your main module file name
config:
...
eif:
...
chains:
ethereum: # Your EVM chain name (bsc, ethereum, sepolia, bsc (same chain name for testnet of bsc), soon more)
network_id: 1 # Network ID of the EVM chain
contracts_to_fetch:
- address: '0x8a2279d4a90b6fe1c4b30fa660cc9f926797baa2' # CHR token contract address
skip_to_height: 17024400 # Skip to the height of the contract
- address: '0xC7b0F970c1EFBB181194Fc15ccD5C4a2c2Ab863B' # CHR stake contract address
skip_to_height: 17024400 # Skip to the height of the contract
evm_read_offset: 3 # EVM read offset doesn't need to change it
read_offset: 2 # Read offset doesn't need to change it
events: !include ./config/events.yaml # Events to fetch include the events you want to fetch from the contracts
bsc:
network_id: 56
contracts_to_fetch:
- address: '0xf9CeC8d50f6c8ad3Fb6dcCEC577e05aA32B224FE' # Bsc CHR token contract address
skip_to_height: 42419297 # Skip to the height of the contract
- address: '0x6414FbBf1CC9d9253125e106435619577bAAc2aC' # Bsc CHR stake contract address
skip_to_height: 42419297 # Skip to the height of the contract
evm_read_offset: 3 # EVM read offset doesn't need to change it
read_offset: 2 # Read offset doesn't need to change it
events: !include ./config/events.yaml # Events to fetch include the events you want to fetch from the contracts
...
moduleArgs:
...
lib.governance.extensions.eif.erc20_chr:
required_total_evm_chr_staked_balance_for_registration: 1000000000 # 1000 CHR
required_total_evm_chr_balance_for_registration: 1000000000 # 1000 CHR
And events.yaml :
# events.yaml
- anonymous: 0
inputs:
- indexed: 1
name: from
type: address
- indexed: 1
name: to
type: address
- indexed: 0
name: value
type: uint256
name: Transfer
type: event
- anonymous: 0
inputs:
- indexed: 1
name: from
type: address
- indexed: 0
name: balance
type: uint64
name: StakeUpdate
type: event
erc20_chr_vote_power_strategies.rell
This custom module can be imported to add a total EVM CHR balance vote power calculation strategy that can be used on proposals.
Requires exactly same configuration as erc20_chr module. And it activates erc20_chr module automatically.
vote_requirements.rell
This custom module can be imported to add a vote requirement that checks your specified evm token symbol and specified balance amount to restrict users that have less than specified balance amount from voting.
Only import the module into your dapp; no additional configuration is required.