How to make a proposal?
Main Smart Contract Methods
The onProposalFinshed method
The main method is onProposalFinished, which is the hook function called when the proposal is finished. The method will receive these parameters:
1
// SPDX-License-Identifier: MIT
2
pragma solidity >=0.6.0 <0.9.0;import "@votilityprotocol/smartcontracts/contracts/IVotilityReceiver.sol";contract DAOTreasury is IVotilityReceiver { receive() external payable {} function onProposalFinished(
3
address sender,
4
uint256 proposalId,
5
bytes32[] calldata data,
6
uint256 winnerOptionIndex,
7
bytes32 winnerOptionData) external override returns (bool) {
8
} function checkProposer(address proposer)
9
external
10
pure
11
override
12
returns (bool) {
13
return true;
14
} function checkERC20VotingPower(address erc20VotingPower)
15
external
16
pure
17
override
18
returns (bool) {
19
return true;
20
} function getMininimumQuorum()
21
external
22
pure
23
override
24
returns (uint256) {
25
return 0;
26
} function getMinimumBlockLimitInterval()
27
external
28
pure
29
override
30
returns (uint8) {
31
return 0;
32
}
33
}
Copied!
​
    address sender: the original sender (who finishes the proposal)
    uint256 proposalId: the proposal id in Votility Protocol
    bytes32[] calldata data: all the input parameters
    uint256 winnerOptionIndex: the winner option index (indexes by zero)
    bytes32 winnerOptionData: the bytes32 data linked to the option
function onProposalFinished( address sender, uint256 proposalId, bytes32[] calldata data, uint256 winnerOptionIndex, bytes32 winnerOptionData)
external override returns (bool) { uint256 amount = uint256(data[0]);
address payable target = address(uint160(uint256(data[1])));
1
if (winnerOptionIndex == 0) {
2
target.transfer(amount);
3
}
4
​
5
return true;
Copied!
The OnProposalFinshed event
The event that finalizes the process is the call of the onProposalFinshed function. This function receives the parameters that characterize the proposal:
● sender: the user who made the proposal finalization call.
● proposalId: unique identifier of the proposal, it is used to get other proposal data in the main Votility Protocol smart contract call.
● data: array that corresponds to the input parameters. The input parameters are mapped into bytes32 variables that can be easily converted to other primary types.
● winnerOptionIndex: index of the winning option starting from zero.
● winnerOptionData: the content of the winning option. For proposals that are based on Yes and No type answers, the index check (winnerOptionIndex parameter) is enough, for more complex proposals the conversion of the winner option content (winnerOptionValue parameter) will be required. And for those proposals that need to retrieve the voting result, just request the complete data through the proposal's unique identification (proposalId parameter).
Last modified 3mo ago
Copy link