You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/governance/governance-interaction.md
+92-58Lines changed: 92 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ title: Governance interaction
7
7
8
8
### Introduction
9
9
10
-
The interaction with the governance system smartcontract is done through correctly formatted transactions to submit actions and through the usage of the vm-query REST API calls for reading the proposal(s) status.
10
+
The interaction with the governance system smartcontract is done through correctly formatted transactions to submit actions and through the usage of the vm-query REST API calls for reading the proposal(s) status.
11
11
12
12
[comment]: #(mx-context-auto)
13
13
@@ -19,7 +19,7 @@ The proposal creation transaction has the following parameters:
The value parameter represents the mandatory proposal submission deposit of 500 EGLD.
32
+
31
33
The proposal identifier is a hex string containing exactly 40 characters. Usually, this can be a git commit hash on which the proposal is made but can be any other identifier string.
32
34
33
-
The starting & ending epochs should be an even-length hex string containing the starting epoch and the ending epoch. During this time frame the votes can be cast.
35
+
The starting & ending epochs should be an even-length hex string containing the starting epoch and the ending epoch. During this time frame, lasting 10 days, the votes can be cast.
36
+
37
+
>**Note:** When providing the starting epoch, it should be taken into consideration that the governance contract enforcing a configured maximum gap of 30 epochs between the current epoch and the proposal’s starting epoch.
34
38
35
39
After issuing the proposal, there is a log event generated having the `proposal` identifier that will contain the following encoded topics:
36
40
@@ -43,7 +47,7 @@ After issuing the proposal, there is a log event generated having the `proposal`
43
47
44
48
### Voting a proposal using the direct staked or delegation-system amount
45
49
46
-
Any wallet that has staked EGLD (either direct staked or through the delegation sub-system) can cast a vote for a proposal.
50
+
Any wallet that has staked EGLD (either direct staked or through the delegation sub-system) can cast a vote for a proposal.
The value parameter for the voting transaction must be set to 0, since the function is non-payable.
64
+
59
65
The `nonce` is the hex encoded value of the proposal's unique nonce and the `vote_type` can be one of the following values:
60
66
- for **Yes**: `796573`;
61
67
- for **No**: `6e6f`;
@@ -64,12 +70,21 @@ The `nonce` is the hex encoded value of the proposal's unique nonce and the `vot
64
70
65
71
The vote value for the account that will vote a proposal is the sum of all staked values along with the sum of all delegated values in the delegation sub-system.
66
72
73
+
After issuing the vote, a log event is generated containing the `proposal` identifier and the following encoded topics:
74
+
75
+
-`nonce` as encoded integer which uniquely identifies the proposals
76
+
-`vote_type` as encoded string representing the vote
77
+
-`total_stake` total staked EGLD for the sender address
78
+
-`total_voting_power` total available voting power for the sender address
79
+
67
80
[comment]: #(mx-context-auto)
68
81
69
82
### Voting a proposal through smart contracts (delegation voting)
70
83
71
84
Whenever we deal with a smart contract that delegated through the delegation sub-system or owns staked nodes it is the out of scope of the metachain's governance contract to track each address that sent EGLD how much is really staked (if any EGLD is staked).
85
+
72
86
That is why we offered an endpoint to the governance smart contact that can be called **only by a shard smart contract** and the governance contract will record the address provided, the vote type and vote value.
87
+
73
88
This is very useful whenever implementing liquid-staking-like smart contracts. The liquid-staking contract knows the balance for each user, so it will delegate the call to the governance contract providing the value.
The value parameter for the voting transaction must be set to 0, since the function is non-payable.
109
+
93
110
The `nonce` is the hex encoded value of the proposal's unique nonce and the `vote_type` can be one of the following values:
94
111
- for **Yes**: `796573`;
95
112
- for **No**: `6e6f`;
96
113
- for **Abstain**: `6162737461696e`;
97
114
- for **Veto**: `7665746f`.
98
115
99
116
The `account address handled by the smart contract` is the address handled by the smart contract that will delegate the vote towards the governance smart contract. This address will be recorded for casting the vote.
117
+
100
118
The `vote_balance` is the amount of stake the address has in the smart contract. The governance contract will "believe" that this is the right amount as it impossible to verify the information. The balance will diminish the total voting power the smart contract has.
101
119
120
+
After issuing the vote, a log event is generated containing the `proposal` identifier and the following encoded topics:
121
+
122
+
-`nonce` as encoded integer which uniquely identifies the proposals
123
+
-`vote_type` as encoded string representing the vote
124
+
-`voter` account address handled by the smart contract
125
+
-`total_stake` total staked EGLD for the sender address
126
+
-`total_voting_power` total available voting power for the sender address
127
+
102
128
[comment]: #(mx-context-auto)
103
129
104
130
### Closing a proposal
105
131
106
-
A proposal can be closed only in an epoch that is strictly higher than the end epoch value provided when the proposal was open.
132
+
A proposal can be closed only in an epoch that is strictly higher than the end epoch value provided when the proposal was opened.
133
+
Closing can only be performed by the account that created the proposal (the issuer).
Only the address that created the proposal can call the `closeProposal` function that will also trigger the funds unlocking. As stated in the overview page, if the proposal does not pass, the amount returned will be less with 10 EGLD.
120
-
145
+
#### Rules for closing
146
+
- Only the issuer can call `closeProposal`.
147
+
- If the proposal **passes** → the full proposal fee is refunded.
148
+
- If the proposal **fails** or is **vetoed** → the refund is reduced by the `LostProposalFee`.
149
+
- Once a proposal is closed, it cannot be reopened.
150
+
- Closing also finalizes the vote tally (the proposal is marked as `Passed` or not, based on the results).
151
+
152
+
121
153
[comment]: #(mx-context-auto)
122
154
123
155
### Querying the status of a proposal
124
156
125
-
The status of a certain proposal can be queried at any time by using the`vm-values/query` REST API endpoints provided by the gateway/API.
157
+
The status of any proposal can be queried at any time through`vm-values/query` REST API endpoints provided by the gateway/API.
the `address` represents the address in hex format. The response will contain the following json definition where all fields are base64-encoded:
234
+
-`proposal_nonce` → the proposal identifier (nonce, hex-encoded).
235
+
-`address` → the bech32 address of the account to check.
236
+
237
+
> **Note:** The older function `viewUserVoteHistory` (which returned lists of proposal nonces) is now considered legacy.
238
+
> Use `viewDelegatedVoteInfo` for detailed voting power and stake information.
239
+
240
+
The response will contain the following json definition where all fields are base64-encoded:
201
241
202
242
```json
203
243
{
204
244
"returnData": [
205
-
"<the number of delegated nonces>",
206
-
"<delegated nonce 0>",
207
-
"<delegated nonce 1>",
208
-
...
209
-
"<delegated nonce n>",
210
-
"<the number of direct nonces>",
211
-
"<direct nonce 0>",
212
-
"<direct nonce 1>",
213
-
...
214
-
"<direct nonce m>"
245
+
"<used_power>", (voting power already used by this address on the proposal)
246
+
"<used_stake>", (stake associated with the used power)
247
+
"<total_power>", (total available voting power for the address)
248
+
"<total_stake>"(total stake considered in governance for the address)
215
249
]
216
250
}
217
251
```
218
252
219
-
Example for an address that cast votes on 5 proposals:
253
+
Example for an address that voted:
220
254
```json
221
255
{
222
256
"returnData": [
223
-
"Aw==", (number of delegated nonces: 3)
224
-
"AQ==", (nonce: 1)
225
-
"Ag==", (nonce: 2)
226
-
"Aw==", (nonce: 3)
227
-
"Ag==", (number of direct nonces: 2)
228
-
"BA==", (nonce: 4)
229
-
"BQ==", (nonce: 5)
257
+
"Cg==", (used power: 10)
258
+
"ZAA=", (used stake: 100)
259
+
"A+g=", (total power: 1000)
260
+
"Gg4M=", (total stake: 10000)
230
261
]
231
262
}
232
263
```
264
+
In this example, the queried address voted on this proposal with **100 stake**, which translated into **10 voting power**. The proposal overall had **10000 total stake** and **1000 total voting power** recorded.
233
265
234
-
Example for an address that did not cast votes on any proposals:
0 commit comments