How setting voting period for each proposal?

Hi! I built simple dao based on contracts wizard, everything is work, but i don't understand how setting voting period for each proposal from front. I cant find solution on forum, i will be glade for help

Hey olgabogdanovanew,

Welcome to the community!

To get your proposal to have a voting period (time limit), you need to make sure your proposal is an object which contains the time it was created.

struct Proposal {
 string name;
 uint256 time;
}

Then, when you create the proposal in a createProposal function, you can set the value of the created proposal to block.timestamp which contains the current time.

Afterward, when you vote, you can check whether the block.timestamp is less greater than the proposal time.
Furthermore, you can have a bool flag of isActive for the front end to determine whether the proposal is active.

1 Like

Hello @olgabogdanovanew

OZ governor do not use block.timestamp as @yanukadeneth99 says.It uses block.number.

The current implementation, which is based on compound's GovernorBravo, doesn't support vote of different length. The main reason are:

  • you don't want the proposer to be able to make the vote short, as it would favor him and his friends (who know the vote is comming) to other users that may not have time to react and oppose.
  • long votes are just not really needed. If you thinkg some proposal needs discussion time before the vote ends, you can always organize this offchain, and only start the vote when everybody had time to argue.

Therefore, it is simpler to just have one vote duraction. You can change this duration by overriding the votingPeriod() function. But please be carefull doing so, as it could create attack vectors.

1 Like

Oh. Thanks for the correction! @Amxx