Skip to main content

Energi Blacklist Governance Coding Example

1. Introduction

Governance in blockchain refers to the processes and mechanisms for making decisions, enforcing rules, and managing the operation and evolution of a blockchain network. It encompasses decision-making, rule enforcement, participation incentives, upgrades and maintenance, community engagement, and dispute resolution. Blockchain governance is particularly important because blockchains are often decentralized, relying on a network of participants. Effective governance ensures that decisions are made collectively and transparently, maintaining the decentralization, security, and integrity of the blockchain while accommodating the evolving needs and preferences of the community. Governance within the Energi Blockchain is managed by the masternodes.

This document provides step-by-step instructions on:

  • How to create proposals to blacklist a wallet address
  • Vote on the proposals
  • Recover funds from the wallet address
  • Compensate the legitimate owner

The example in this document is shown for the NRG token. It can be used for any token listed on the Energi blockchain.

2. Pre-Requisites

You need to run a fully sync-ed masternode to be able to run the commands. We will use the Energi Core testnet. They can be executed on the mainnet as well.

You will need 1000 tNRG (test NRG) to set up a masternode. Send an email to support@energi.world with subject Request 2500 tNRG to set up testnet masternode. In the body of the letter include the wallet address where you would like us to send the tNRG to. Also note you are planning to work on blacklist governance on testnet.

Check out the Masternode Guide if you do not have a masternode set up. Use 1000 tNRG to set up the masternode. You will need the remaining to put up collateral for proposals.

3. API Reference

Following reference guide has details on the modules used in this document:

4. Blacklist Governance

4.1. blacklistEnforce Proposal

4.1.1. Create blacklistEnforce Proposal

Invoke the blacklistEnforce method to create a proposal. It includes the target account which will be blacklisted. This will be voted on by the governance system. A 1000 NRG refundable fee is required when creating the proposal.

ClientMethod invocation
Consoleenergi.blacklistEnforce(target, fee, payer[, password])

Command:

energi.blacklistEnforce('0x47e8bb353647d5136f48b8f5d2b011f616ed01ef', web3.toWei('1000', 'nrg'),'0x680cf4b9c12736dbab9eec2a481e6101aacf300a', 'energi123')

Result:

0x31058bb07509bdf4a7f62314b153b25a26abcc233f8a872246d5ddef82ade3fe
undefined

4.1.2. Validate Enforce Proposal

Run the following to verify that the proposal has been successfully generated:

Command:

energi.blacklistInfo()

Result:

[.... , {
blocked: false,
drain: null,
enforce: {
acceptWeight: 0,
accepted: false,
balance: 0,
createdBlock: 92668,
deadline: 1587413837,
finished: false,
proposal: "0x7add616a2bdb84c216bc0c4f5c4b14bbe3b53bcb",
proposer: "0x680cf4b9c12736dbab9eec2a481e6101aacf300a",
quorumWeight: 3.13e+22,
rejectWeight: 0,
totalWeight: 3.13e+23
},
revoke: null,
target: "0x47e8bb353647d5136f48b8f5d2b011f616ed01ef"
},
....

}]

4.2. Masternode Voting on Blacklist Proposal

The blacklist enforce proposal created requires at least 10% of the masternodes to vote positively for it to pass. This voting process ensures community consensus and participation in addressing wallet compromises.

Voting can be either an voteAccept or voteReject.

4.2.1. voteAccept

ClientMethod invocation
Consoleenergi.voteAccept(proposal, mn_owner[, password])

Command:

energi.voteAccept('0x6024af57b02f9979d48f0f0756b87b56e793fa6d', '0x8978e517c2b442264e54b890c4428816b66aaf8b', 'Energi123')

Result:

0x51627be46bc003030bf4c43e7ebb686d35cfaf633edbb6544a0beda16fb967e1
undefined

4.2.2. voteReject

ClientMethod invocation
Consoleenergi.voteReject(proposal, mn_owner[, password])

Command:

energi.voteReject('0x6024af57b02f9979d48f0f0756b87b56e793fa6d', '0x8978e517c2b442264e54b890c4428816b66aaf8b', 'Energi123')

Result:

0x52c3f415baacdddd147c9c5c7d609e59f056c2cb6f098565a8591dcd55ebbc4e
undefined
4.2.2.1. Exception #1: You will get an error if you try to vote again

Command:

energi.voteReject('0x6024af57b02f9979d48f0f0756b87b56e793fa6d', '0x8978e517c2b442264e54b890c4428816b66aaf8b', 'Energi123')

Result:

Error: This account is not allowed to vote!
at web3.js:3164:20
at web3.js:6368:15
at web3.js:5102:36
at <anonymous>:1:1
4.2.2.2. Exception #2: You will get an error if you try to vote with a masternode that was announced after the proposal was created.

Command:

energi.voteReject('0x6024af57b02f9979d48f0f0756b87b56e793fa6d', '0x680cf4b9c12736dbab9eec2a481e6101aacf300a', 'energi123')

Result:

Error: This account is not allowed to vote!
at web3.js:3164:20
at web3.js:6368:15
at web3.js:5102:36
at <anonymous>:1:1

4.3. Drain Proposal

A drain proposal is submitted to the blockchain for a vote. The drain proposal aims to address the compromised wallet and recover the funds for the victim. You need to put up 100 NRG as collateral.

ClientMethod invocation
Consoleenergi.blacklistDrain(target, fee, payer[, password])

Command:

energi.blacklistDrain('0x9979a36db71eaac8ef927f14bf01a18aba6c0276', web3.toWei('100', 'nrg'),  '0x680cf4b9c12736dbab9eec2a481e6101aacf300a', 'energi123')

Result:

0x2e9891cf72fdc71406a6493549092aa1bf6a6733e4e6cea4e8057051ca71d30e
undefined

Validation Command:

energi.blacklistInfo()

Result:

[{
....
{
blocked: true,
drain: {
acceptWeight: 0,
accepted: false,
balance: 0,
createdBlock: 92823,
deadline: 1587423099,
finished: false,
proposal: "0x33d2e1e0716afbf3e5f4cd65e4b8252ca8a0239e",
proposer: "0x680cf4b9c12736dbab9eec2a481e6101aacf300a",
quorumWeight: 3.13e+22,
rejectWeight: 0,
totalWeight: 3.13e+23
},
enforce: {
acceptWeight: 5e+22,
accepted: true,
balance: 0,
createdBlock: 2269,
deadline: 1581948257,
finished: true,
proposal: "0x96ed7d415fe85661bc7b10d4f683f3f1c63ddfa7",
proposer: "0x25bbaaaf27ab1966c3ab9faf31277a1db7601f3f",
quorumWeight: 2.81e+22,
rejectWeight: 3e+22,
totalWeight: 2.81e+23
},
revoke: null,
target: "0x9979a36db71eaac8ef927f14bf01a18aba6c0276"
}
...
}]

4.4. Masternode Voting on Drain Proposal

The drain proposal created requires at least 10% of the masternodes to vote positively for it to pass. This voting process ensures community consensus and participation in addressing wallet compromises.

See section 4.2 above on how to either cast a voteAccept or voteReject on the proposal.

4.5. Compensate Proposal

A compensate proposal is submitted to the blockchain to pay back the funds to the victim. The proposal requires 100 NRG as collateral.

ClientMethod invocation
Consoleenergi.compensationPropose(amount, uuid, period, fee, payer [,password])

Command:

energi.compensationPropose(web3.toWei('30000', 'ether'), 'e04d90cd-e4e0-4557-937e-00ff6d106a87', 1296000, web3.toWei('100', 'ether'), "0xa229362a827aa052babc8989d5fc2dc669e18f81", 'Energi123')

Result:

0xa5ef068b6a0b30ec518d7b2bebae15c0cb3ec3993c12dfef44609fb31fbcc6a6
undefined

Verify Command

Run the following command o verify that the proposal has been successfully generated.

energi.compensationInfo()

Result:

{
balance: 3.5612486184063e+23,
proposals: [...
{
acceptWeight: 0,
accepted: false,
balance: 0,
createdBlock: 92860,
deadline: 1588116552,
finished: false,
paidAmount: 0,
proposal: "0xcc35937d9b2b3a998c4a6b87483d1e2b3a818717",
proposedAmount: 3e+22,
proposer: "0xa229362a827aa052babc8989d5fc2dc669e18f81",
quorumWeight: 2.191e+22,
refUUID: "e04d90cd-e4e0-4557-937e-00ff6d106a87",
rejectWeight: 0,
totalWeight: 3.13e+23
}
...]
}

4.6. Masternode Voting on Compensate Proposal

The compensate proposal requires at least 10% positive vote from all masternodes. If and when all the prerequisites are met, the funds will be returned to the legitimate owner.

See section 4.2 above on how to either cast a voteAccept or voteReject on the proposal.

4.7. Claim Refundable Fee

The blacklistCollect method allows you to claim the refundable fee used to generate a proposal by any of the methods:_blacklistEnforce ,_blacklistRevoke and _blacklistDrain.

ClientMethod invocation
Consoleenergi.blacklistCollect(proposal, payer[,password])

Command:

energi.blacklistCollect('0xa6f6bc8b5d50d15bd1838609f23eb5a353948c0f','0x680cf4b9c12736dbab9eec2a481e6101aacf300a', 'energi123')

Result:

0x3b314120dcc1a26527ab8dbba27755b0c249029673d2908591a6275835d69a3d
undefined

Go to Energi Block Explorer - Testnet to verify that the fee has been refunded

Success

Congratulations! You have successfully completed all the steps to blacklist and claim the funds from a wallet address.