question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add the possibility to include ERC721 token voting within OZ Governor module

See original GitHub issue

🧐 Motivation As stated in the governance introductory article:

OpenZeppelin Contracts contain the most common requirements out of the box. Beyond these, OpenZeppelin Governor could potentially be configured with ERC721 voting power so certain NFT owners can participate in governance when specified.

I was wondering if such possibility is already explored somewhere or not yet… I imagine the customization and usecases could be infinite, but what would imply to have a basic version of the OZ Governor that uses ERC721 tokens to create proposals, delegate and vote?

This issue is a continuation of the https://github.com/OpenZeppelin/openzeppelin-contracts/issues/2868 one. In this thread I explain a little bit more the usecase I’m working on.

šŸ“ Details Following @Amxx suggestions I drafted 3 new contracts:

  • GovernorERC721Votes: A new governance flavor extension for voting weight extraction from an ERC721Votes token.
  • ERC721Votes: A clone of ERC20Votes, with the same functions - included getPastVotes - but that inherits NFTPermit instead of draft-ERC20Permit
  • NFTPermit: A draft implementation of Permit for the ERC721 token (taken from here)

As I am not really proficient with solidity, I expect there’s lot of devil in the details when implementing even the most trivial things, so I was wondering if I’m totally out of track or not?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Amxxcommented, Mar 15, 2022

@omer2307 It’s marked as draft because it depends on EIP712, which is not final

1reaction
Amxxcommented, Oct 27, 2021

I can’t say we thought about this.

We considered that the uint8 support, introduced by bravo, could be used in many different ways? It can be an enum, but it could also be a ranking. These ā€œgradesā€ would be used to compute the weighted average and decide the outcome of the vote.

For maximum bravo compatibility, we wanted our external function to share the same signature, so we couldn’t add/remove or even change the types of the existing parameters. That being said, if you want to implement your approach, you can have the castVote, castVoteWithReason and castVoteBySig function disabled (by overriding _castVote with an empty function that reverts, and add functions of you own.

Interfaces that are commonly use to vote on compound like governors will not be able to have users vote, but the rest of the system (proposal / queueing/ execution) should be transparent.

you system would have to :

  • create new public voting function
  • extract the weight of each vote
  • prevent double voting
  • implement the _quorumReached and _voteSucceeded function

Note, the propose function requires getVotes to exist, so you may need to expose something like the NFT balance even though you don’t use that for the actual voting

Read more comments on GitHub >

github_iconTop Results From Across the Web

Governance - OpenZeppelin Docs
Votes modules determine the source of voting power, and sometimes quorum number. GovernorVotes : Extracts voting weight from an ERC20Votes token.
Read more >
Adding DAO Governance to Existing Token Contracts
You can turn your token contract into a DAO by adding a Governor Contract to manage proposals and votes for your DAO.
Read more >
Governor Module: Operator Tutorial - Gnosis zodiac.wiki
There are two major steps to add a Governor Module to your Safe: (1) set up a token for voting, and (2) set...
Read more >
How to add DAO governance to existing token contracts - Tally
You can turn your token contract into a DAO by adding a Governor Contract to manage proposals and votes for your DAO.
Read more >
Full Reference | thirdweb developer portal
This implements an optional extension of defined in the EIP that adds enumerability of all the token ids in the contract as well...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found