Skip to content

Commit c2d4b87

Browse files
authored
Merge pull request #1145 from LaraTifui/governance-update
docs (governance): update interactions and overview
2 parents 36067fb + d64eff3 commit c2d4b87

File tree

2 files changed

+165
-91
lines changed

2 files changed

+165
-91
lines changed

docs/governance/governance-interaction.md

Lines changed: 92 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Governance interaction
77

88
### Introduction
99

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

1212
[comment]: # (mx-context-auto)
1313

@@ -19,7 +19,7 @@ The proposal creation transaction has the following parameters:
1919
GovernanceProposalTransaction {
2020
Sender: <account address of the wallet that creates the proposal>
2121
Receiver: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrlllsrujgla
22-
Value: 1000 EGLD
22+
Value: 500 EGLD
2323
GasLimit: 51000000
2424
Data: "proposal" +
2525
"@<identifier>" +
@@ -28,9 +28,13 @@ GovernanceProposalTransaction {
2828
}
2929
```
3030

31+
The value parameter represents the mandatory proposal submission deposit of 500 EGLD.
32+
3133
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.
3234

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.
3438
3539
After issuing the proposal, there is a log event generated having the `proposal` identifier that will contain the following encoded topics:
3640

@@ -43,7 +47,7 @@ After issuing the proposal, there is a log event generated having the `proposal`
4347

4448
### Voting a proposal using the direct staked or delegation-system amount
4549

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.
4751
```rust
4852
GovernanceVoteTransaction {
4953
Sender: <account address of the wallet that will vote the proposal>
@@ -56,6 +60,8 @@ GovernanceVoteTransaction {
5660
}
5761
```
5862

63+
The value parameter for the voting transaction must be set to 0, since the function is non-payable.
64+
5965
The `nonce` is the hex encoded value of the proposal's unique nonce and the `vote_type` can be one of the following values:
6066
- for **Yes**: `796573`;
6167
- for **No**: `6e6f`;
@@ -64,12 +70,21 @@ The `nonce` is the hex encoded value of the proposal's unique nonce and the `vot
6470

6571
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.
6672

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+
6780
[comment]: # (mx-context-auto)
6881

6982
### Voting a proposal through smart contracts (delegation voting)
7083

7184
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+
7286
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+
7388
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.
7489

7590
:::important
@@ -90,39 +105,56 @@ GovernanceVoteThourghDelegationTransaction {
90105
}
91106
```
92107

108+
The value parameter for the voting transaction must be set to 0, since the function is non-payable.
109+
93110
The `nonce` is the hex encoded value of the proposal's unique nonce and the `vote_type` can be one of the following values:
94111
- for **Yes**: `796573`;
95112
- for **No**: `6e6f`;
96113
- for **Abstain**: `6162737461696e`;
97114
- for **Veto**: `7665746f`.
98115

99116
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+
100118
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.
101119

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+
102128
[comment]: # (mx-context-auto)
103129

104130
### Closing a proposal
105131

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).
107134

108135
```rust
109136
CloseProposalTransaction {
110-
Sender: <account address of the wallet that created the proposal>
137+
Sender: <account address of the wallet that created the proposal>
111138
Receiver: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrlllsrujgla
112-
Value: 0 EGLD
139+
Value: 0 EGLD
113140
GasLimit: 51000000
114-
Data: "closeProposal" +
115-
"@<nonce>"
141+
Data: "closeProposal" +
142+
"@<nonce>"
116143
}
117144
```
118-
119-
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+
121153
[comment]: # (mx-context-auto)
122154

123155
### Querying the status of a proposal
124156

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

127159
```bash
128160
https://<gateway>.multiversx.com/vm-values/query
@@ -132,52 +164,54 @@ https://<gateway>.multiversx.com/vm-values/query
132164
{
133165
"scAddress": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrlllsrujgla",
134166
"funcName": "viewProposal",
135-
"args": ["<nonce>"]
167+
"args": ["<nonce-hex>"]
136168
}
137169
```
138170

139-
the `nonce` represents the proposal nonce in hex format. The response will contain the following json definition where all fields are base64-encoded:
171+
- The argument `nonce` is the proposal nonce in hex format.
172+
- The response will contain the following json definition where all fields are base64-encoded:
140173

141174
```json
142175
{
143176
"returnData": [
144-
"<proposal_cost>",
145-
"<commit_hash>",
146-
"<nonce>",
147-
"<account address of the wallet that created the proposal>",
148-
"<starting epoch>",
149-
"<ending epoch>",
150-
"<quorum stake>",
151-
"<yes_value>",
152-
"<no_value>",
153-
"<veto_value>",
154-
"<abstain_value>",
177+
"<proposal_cost>", (amount locked by proposer)
178+
"<commit_hash>", (unique identifier of the proposal)
179+
"<nonce>", (proposal number)
180+
"<issuer_address>", (address of the proposer)
181+
"<start_epoch>", (epoch when voting starts)
182+
"<end_epoch>", (epoch when voting ends)
183+
"<quorum_stake>", (current quorum stake: sum of stake that participated)
184+
"<yes_votes>", (total stake voting YES)
185+
"<no_votes>", (total stake voting NO)
186+
"<veto_votes>", (total stake vetoing the proposal)
187+
"<abstain_votes>", (total stake abstaining)
155188
"<proposal_closed true|false>",
156189
"<proposal_passed true|false>"
157190
]
158191
}
159192
```
160193

161-
Example:
194+
Example response:
162195
```json
163196
{
164197
"returnData": [
165198
"NjXJrcXeoAAA", (proposal locked amount: 1000 EGLD denominated = 1000 * 10^18)
166199
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABg==", (commit hash: 0x0000...006)
167200
"AQ==", (nonce: 1)
168-
"aj88GtqHy9ibm5ePPQlG4aqLhpgqsQWygoTppckLa4M=", (address: erd1dglncxk6sl9a3xumj78n6z2xux4ghp5c92cstv5zsn56tjgtdwpsk46qrs)
201+
"aj88GtqHy9ibm5ePPQlG4aqLhpgqsQWygoTppckLa4M=", (proposer address)
169202
"bQ==", (starting epoch: 109)
170203
"bg==", (ending epoch: 110)
171-
"ntGU2xmyOMAAAA==", (quorum: 750000 EGLD = 7500000 * 10^18)
172-
"", (yes value: 0)
173-
"", (no value: 0)
174-
"ntGU2xmyOMAAAA==", (veto value: 7500000 * 10^18)
175-
"", (abstain value: 0)
204+
"ntGU2xmyOMAAAA==", (quorum: 7,500,000 EGLD denominated)
205+
"", (yes votes: 0)
206+
"", (no votes: 0)
207+
"ntGU2xmyOMAAAA==", (veto votes: 7,500,000 EGLD denominated)
208+
"", (abstain votes: 0)
176209
"dHJ1ZQ==", (proposal closed: true)
177210
"ZmFsc2U=" (proposal passed: false)
178211
]
179212
}
180-
```
213+
214+
181215

182216
[comment]: # (mx-context-auto)
183217

@@ -192,51 +226,51 @@ https://<gateway>.multiversx.com/vm-values/query
192226
```json
193227
{
194228
"scAddress": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrlllsrujgla",
195-
"funcName": "viewUserVoteHistory",
196-
"args": ["<address>"]
229+
"funcName": "viewDelegatedVoteInfo",
230+
"args": ["<proposal_nonce-hex>", "<address>"]
197231
}
198232
```
199233

200-
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:
201241

202242
```json
203243
{
204244
"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)
215249
]
216250
}
217251
```
218252

219-
Example for an address that cast votes on 5 proposals:
253+
Example for an address that voted:
220254
```json
221255
{
222256
"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)
230261
]
231262
}
232263
```
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.
233265

234-
Example for an address that did not cast votes on any proposals:
266+
Example for an address that did not vote:
235267
```json
236268
{
237269
"returnData": [
238-
"AA==", (number of delegated nonces: 0)
239-
"AA==", (number of direct nonces: 0)
270+
"AA==", (used power: 0)
271+
"AA==", (used stake: 0)
272+
"A+g=", (total power: 1000)
273+
"Gg4M=", (total stake: 10000)
240274
]
241275
}
242276
```

0 commit comments

Comments
 (0)