Request form
Basic DAO
  • DAO
  • Governance
Docs
Source
ChefGPT

Basic DAO

A very simple implementation of a DAO. Voting period is locked in at 1 week, and the voting delay is 1 block. There is no delay on approved proposals.

SimpleDAO :
A very simple implementation of a DAO. Voting period is locked in at 1 week, and the voting delay is 1 block. There is no delay on approved proposals.
COUNTING_MODE() :
See {IGovernor-COUNTING_MODE}.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
See {IGovernor-hasVoted}.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
proposalVotes(uint256) :
Accessor to the internal vote counts.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorumDenominator() :
Returns the quorum denominator. Defaults to 100, but may be overridden.
quorumNumerator() :
Returns the current quorum numerator. See {quorumDenominator}.
quorumNumerator(uint256) :
Returns the quorum numerator at a specific block number. See {quorumDenominator}.
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
updateQuorumNumerator(uint256) :
Changes the quorum numerator. Emits a {QuorumNumeratorUpdated} event. Requirements: - Must be called through a governance proposal. - New numerator must be smaller or equal to the denominator.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
Governor :
Core of the governance system, designed to be extended though various modules. This contract is abstract and requires several function to be implemented in various modules: - A counting module must implement {quorum}, {_quorumReached}, {_voteSucceeded} and {_countVote} - A voting module must implement {_getVotes} - Additionanly, the {votingPeriod} must also be implemented _Available since v4.3._
COUNTING_MODE() :
A description of the possible `support` values for {castVote} and the way these votes are counted, meant to be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. There are 2 standard keys: `support` and `quorum`. - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. - `quorum=bravo` means that only For votes are counted towards quorum. - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique name that describes the behavior. For example: - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] JavaScript class.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
constructor :
Sets the value for {name} and {version}
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
Returns weither `account` has cast a vote on `proposalId`.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorum(uint256) :
Minimum number of cast voted required for a proposal to be successful. Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}).
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
GovernorCountingSimple :
Extension of {Governor} for simple, 3 options, vote counting. _Available since v4.3._
COUNTING_MODE() :
See {IGovernor-COUNTING_MODE}.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
See {IGovernor-hasVoted}.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
proposalVotes(uint256) :
Accessor to the internal vote counts.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorum(uint256) :
Minimum number of cast voted required for a proposal to be successful. Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}).
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
GovernorVotes :
Extension of {Governor} for voting weight extraction from an {ERC20Votes} token, or since v4.5 an {ERC721Votes} token. _Available since v4.3._
COUNTING_MODE() :
A description of the possible `support` values for {castVote} and the way these votes are counted, meant to be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. There are 2 standard keys: `support` and `quorum`. - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. - `quorum=bravo` means that only For votes are counted towards quorum. - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique name that describes the behavior. For example: - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] JavaScript class.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
Returns weither `account` has cast a vote on `proposalId`.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorum(uint256) :
Minimum number of cast voted required for a proposal to be successful. Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}).
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
GovernorVotesQuorumFraction :
Extension of {Governor} for voting weight extraction from an {ERC20Votes} token and a quorum expressed as a fraction of the total supply. _Available since v4.3._
COUNTING_MODE() :
A description of the possible `support` values for {castVote} and the way these votes are counted, meant to be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. There are 2 standard keys: `support` and `quorum`. - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. - `quorum=bravo` means that only For votes are counted towards quorum. - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique name that describes the behavior. For example: - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] JavaScript class.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
constructor :
Initialize quorum as a fraction of the token's total supply. The fraction is specified as `numerator / denominator`. By default the denominator is 100, so quorum is specified as a percent: a numerator of 10 corresponds to quorum being 10% of total supply. The denominator can be customized by overriding {quorumDenominator}.
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
Returns weither `account` has cast a vote on `proposalId`.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorum(uint256) :
Returns the quorum for a block number, in terms of number of votes: `supply * numerator / denominator`.
quorumDenominator() :
Returns the quorum denominator. Defaults to 100, but may be overridden.
quorumNumerator() :
Returns the current quorum numerator. See {quorumDenominator}.
quorumNumerator(uint256) :
Returns the quorum numerator at a specific block number. See {quorumDenominator}.
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
updateQuorumNumerator(uint256) :
Changes the quorum numerator. Emits a {QuorumNumeratorUpdated} event. Requirements: - Must be called through a governance proposal. - New numerator must be smaller or equal to the denominator.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
IERC721Receiver :
Interface for any contract that wants to support safeTransfers from ERC721 asset contracts.
onERC721Received(address,address,uint256,bytes) :
Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} by `operator` from `from`, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
IERC1155Receiver :
_Available since v3.1._
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. NOTE: To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector).
onERC1155Received(address,address,uint256,uint256,bytes) :
Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. NOTE: To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector).
supportsInterface(bytes4) :
Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
ECDSA :
Elliptic Curve Digital Signature Algorithm (ECDSA) operations. These functions can be used to verify that a message was signed by the holder of the private keys of a given address.
EIP712 :
https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in their contracts using a combination of `abi.encode` and `keccak256`. This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA ({_hashTypedDataV4}). The implementation of the domain separator was designed to be as efficient as possible while still properly updating the chain id to protect against replay attacks on an eventual fork of the chain. NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. _Available since v3.4._
constructor :
Initializes the domain separator and parameter caches. The meaning of `name` and `version` is specified in https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. - `version`: the current major version of the signing domain. NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart contract upgrade].
ERC165 :
Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ``` Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
SafeCast :
Wrappers over Solidity's uintXX/intXX casting operators with added overflow checks. Downcasting from uint256/int256 in Solidity does not revert on overflow. This can easily result in undesired exploitation or bugs, since developers usually assume that overflows raise errors. `SafeCast` restores this intuition by reverting the transaction when such an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always. Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing all math on `uint256` and `int256` and then downcasting.
DoubleEndedQueue :
A sequence of items with the ability to efficiently push and pop items (i.e. insert and remove) on both ends of the sequence (called front and back). Among other access patterns, it can be used to implement efficient LIFO and FIFO queues. Storage use is optimized, and all operations are O(1) constant time. This includes {clear}, given that the existing queue contents are left in storage. The struct is called `Bytes32Deque`. Other types can be cast to and from `bytes32`. This data structure can only be used in storage, and not in memory. ``` DoubleEndedQueue.Bytes32Deque queue; ``` _Available since v4.6._
Address :
Collection of functions related to the address type
Context :
Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.
Timers :
Tooling for timepoints, timers and delays
IGovernor :
Interface of the {Governor} core. _Available since v4.3._
ProposalCanceled(uint256) :
Emitted when a proposal is canceled.
ProposalCreated(uint256,address,address[],uint256[],string[],bytes[],uint256,uint256,string) :
Emitted when a proposal is created.
ProposalExecuted(uint256) :
Emitted when a proposal is executed.
VoteCast(address,uint256,uint8,uint256,string) :
Emitted when a vote is cast without params. Note: `support` values should be seen as buckets. Their interpretation depends on the voting module used.
VoteCastWithParams(address,uint256,uint8,uint256,string,bytes) :
Emitted when a vote is cast with params. Note: `support` values should be seen as buckets. Their interpretation depends on the voting module used. `params` are additional encoded parameters. Their intepepretation also depends on the voting module used.
COUNTING_MODE() :
A description of the possible `support` values for {castVote} and the way these votes are counted, meant to be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. There are 2 standard keys: `support` and `quorum`. - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. - `quorum=bravo` means that only For votes are counted towards quorum. - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique name that describes the behavior. For example: - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] JavaScript class.
castVote(uint256,uint8) :
Cast a vote Emits a {VoteCast} event.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
Cast a vote using the user's cryptographic signature. Emits a {VoteCast} event.
castVoteWithReason(uint256,uint8,string) :
Cast a vote with a reason Emits a {VoteCast} event.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
Cast a vote with a reason and additional encoded parameters Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
Cast a vote with a reason and additional encoded parameters using the user's cryptographic signature. Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params.
execute(address[],uint256[],bytes[],bytes32) :
Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the deadline to be reached. Emits a {ProposalExecuted} event. Note: some module can modify the requirements for execution, for example by adding an additional timelock.
getVotes(address,uint256) :
Voting power of an `account` at a specific `blockNumber`. Note: this can be implemented in a number of ways, for example by reading the delegated balance from one (or multiple), {ERC20Votes} tokens.
getVotesWithParams(address,uint256,bytes) :
Voting power of an `account` at a specific `blockNumber` given additional encoded parameters.
hasVoted(uint256,address) :
Returns weither `account` has cast a vote on `proposalId`.
hashProposal(address[],uint256[],bytes[],bytes32) :
Hashing function used to (re)build the proposal id from the proposal details..
name() :
Name of the governor instance (used in building the ERC712 domain separator).
proposalDeadline(uint256) :
Block number at which votes close. Votes close at the end of this block, so it is possible to cast a vote during this block.
proposalSnapshot(uint256) :
Block number used to retrieve user's votes and quorum. As per Compound's Comp and OpenZeppelin's ERC20Votes, the snapshot is performed at the end of this block. Hence, voting for this proposal starts at the beginning of the following block.
propose(address[],uint256[],bytes[],string) :
Create a new proposal. Vote start {IGovernor-votingDelay} blocks after the proposal is created and ends {IGovernor-votingPeriod} blocks after the voting starts. Emits a {ProposalCreated} event.
quorum(uint256) :
Minimum number of cast voted required for a proposal to be successful. Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}).
state(uint256) :
Current state of a proposal, following Compound's convention
supportsInterface(bytes4) :
Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
version() :
Version of the governor instance (used in building the ERC712 domain separator). Default: "1"
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
IERC165 :
Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.
supportsInterface(bytes4) :
Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
Strings :
String operations.
IVotes :
Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts. _Available since v4.5._
DelegateChanged(address,address,address) :
Emitted when an account changes their delegate.
DelegateVotesChanged(address,uint256,uint256) :
Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
delegate(address) :
Delegates votes from the sender to `delegatee`.
delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32) :
Delegates votes from signer to `delegatee`.
delegates(address) :
Returns the delegate that `account` has chosen.
getPastTotalSupply(uint256) :
Returns the total supply of votes available at the end of a past block (`blockNumber`). NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes. Votes that have not been delegated are still part of total supply, even though they would not participate in a vote.
getPastVotes(address,uint256) :
Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).
getVotes(address) :
Returns the current amount of votes that `account` has.
Checkpoints :
This library defines the `History` struct, for checkpointing values as they change at different points in time, and later looking up past values by block number. See {Votes} as an example. To create a history of checkpoints define a variable type `Checkpoints.History` in your contract, and store a new checkpoint for the current transaction block using the {push} function. _Available since v4.5._
Math :
Standard math utilities missing in the Solidity language.
basic-dao.sol
Governor.sol
GovernorCountingSimple.sol
GovernorVotes.sol
GovernorVotesQuorumFraction.sol
IERC721Receiver.sol
IERC1155Receiver.sol
ECDSA.sol
draft-EIP712.sol
ERC165.sol
SafeCast.sol
DoubleEndedQueue.sol
Address.sol
Context.sol
Timers.sol
IGovernor.sol
IERC165.sol
Strings.sol
IVotes.sol
Checkpoints.sol
Math.sol

736 downloads

Solidity Version

0.8.12

Creator

Cookbook
Cookbook / Basic DAO
  • DAO
  • Governance
Docs
Source
ChefGPT
Expand
Share

Get Cookin'
star icon736

736 downloads

Solidity Version

0.8.12

Creator

Cookbook

Basic DAO

A very simple implementation of a DAO. Voting period is locked in at 1 week, and the voting delay is 1 block. There is no delay on approved proposals.

SimpleDAO :
A very simple implementation of a DAO. Voting period is locked in at 1 week, and the voting delay is 1 block. There is no delay on approved proposals.
COUNTING_MODE() :
See {IGovernor-COUNTING_MODE}.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
See {IGovernor-hasVoted}.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
proposalVotes(uint256) :
Accessor to the internal vote counts.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorumDenominator() :
Returns the quorum denominator. Defaults to 100, but may be overridden.
quorumNumerator() :
Returns the current quorum numerator. See {quorumDenominator}.
quorumNumerator(uint256) :
Returns the quorum numerator at a specific block number. See {quorumDenominator}.
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
updateQuorumNumerator(uint256) :
Changes the quorum numerator. Emits a {QuorumNumeratorUpdated} event. Requirements: - Must be called through a governance proposal. - New numerator must be smaller or equal to the denominator.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
Governor :
Core of the governance system, designed to be extended though various modules. This contract is abstract and requires several function to be implemented in various modules: - A counting module must implement {quorum}, {_quorumReached}, {_voteSucceeded} and {_countVote} - A voting module must implement {_getVotes} - Additionanly, the {votingPeriod} must also be implemented _Available since v4.3._
COUNTING_MODE() :
A description of the possible `support` values for {castVote} and the way these votes are counted, meant to be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. There are 2 standard keys: `support` and `quorum`. - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. - `quorum=bravo` means that only For votes are counted towards quorum. - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique name that describes the behavior. For example: - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] JavaScript class.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
constructor :
Sets the value for {name} and {version}
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
Returns weither `account` has cast a vote on `proposalId`.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorum(uint256) :
Minimum number of cast voted required for a proposal to be successful. Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}).
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
GovernorCountingSimple :
Extension of {Governor} for simple, 3 options, vote counting. _Available since v4.3._
COUNTING_MODE() :
See {IGovernor-COUNTING_MODE}.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
See {IGovernor-hasVoted}.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
proposalVotes(uint256) :
Accessor to the internal vote counts.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorum(uint256) :
Minimum number of cast voted required for a proposal to be successful. Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}).
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
GovernorVotes :
Extension of {Governor} for voting weight extraction from an {ERC20Votes} token, or since v4.5 an {ERC721Votes} token. _Available since v4.3._
COUNTING_MODE() :
A description of the possible `support` values for {castVote} and the way these votes are counted, meant to be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. There are 2 standard keys: `support` and `quorum`. - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. - `quorum=bravo` means that only For votes are counted towards quorum. - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique name that describes the behavior. For example: - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] JavaScript class.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
Returns weither `account` has cast a vote on `proposalId`.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorum(uint256) :
Minimum number of cast voted required for a proposal to be successful. Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}).
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
GovernorVotesQuorumFraction :
Extension of {Governor} for voting weight extraction from an {ERC20Votes} token and a quorum expressed as a fraction of the total supply. _Available since v4.3._
COUNTING_MODE() :
A description of the possible `support` values for {castVote} and the way these votes are counted, meant to be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. There are 2 standard keys: `support` and `quorum`. - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. - `quorum=bravo` means that only For votes are counted towards quorum. - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique name that describes the behavior. For example: - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] JavaScript class.
castVote(uint256,uint8) :
See {IGovernor-castVote}.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
See {IGovernor-castVoteBySig}.
castVoteWithReason(uint256,uint8,string) :
See {IGovernor-castVoteWithReason}.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
See {IGovernor-castVoteWithReasonAndParams}.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
See {IGovernor-castVoteWithReasonAndParamsBySig}.
constructor :
Initialize quorum as a fraction of the token's total supply. The fraction is specified as `numerator / denominator`. By default the denominator is 100, so quorum is specified as a percent: a numerator of 10 corresponds to quorum being 10% of total supply. The denominator can be customized by overriding {quorumDenominator}.
execute(address[],uint256[],bytes[],bytes32) :
See {IGovernor-execute}.
getVotes(address,uint256) :
See {IGovernor-getVotes}.
getVotesWithParams(address,uint256,bytes) :
See {IGovernor-getVotesWithParams}.
hasVoted(uint256,address) :
Returns weither `account` has cast a vote on `proposalId`.
hashProposal(address[],uint256[],bytes[],bytes32) :
See {IGovernor-hashProposal}. The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in advance, before the proposal is submitted. Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the same proposal (with same operation and same description) will have the same id if submitted on multiple governors across multiple networks. This also means that in order to execute the same operation twice (on the same governor) the proposer will have to change the description in order to avoid proposal id conflicts.
name() :
See {IGovernor-name}.
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
See {IERC1155Receiver-onERC1155BatchReceived}.
onERC1155Received(address,address,uint256,uint256,bytes) :
See {IERC1155Receiver-onERC1155Received}.
onERC721Received(address,address,uint256,bytes) :
See {IERC721Receiver-onERC721Received}.
proposalDeadline(uint256) :
See {IGovernor-proposalDeadline}.
proposalSnapshot(uint256) :
See {IGovernor-proposalSnapshot}.
proposalThreshold() :
Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
propose(address[],uint256[],bytes[],string) :
See {IGovernor-propose}.
quorum(uint256) :
Returns the quorum for a block number, in terms of number of votes: `supply * numerator / denominator`.
quorumDenominator() :
Returns the quorum denominator. Defaults to 100, but may be overridden.
quorumNumerator() :
Returns the current quorum numerator. See {quorumDenominator}.
quorumNumerator(uint256) :
Returns the quorum numerator at a specific block number. See {quorumDenominator}.
relay(address,uint256,bytes) :
Relays a transaction or function call to an arbitrary target. In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. Note that if the executor is simply the governor itself, use of `relay` is redundant.
state(uint256) :
See {IGovernor-state}.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
updateQuorumNumerator(uint256) :
Changes the quorum numerator. Emits a {QuorumNumeratorUpdated} event. Requirements: - Must be called through a governance proposal. - New numerator must be smaller or equal to the denominator.
version() :
See {IGovernor-version}.
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
IERC721Receiver :
Interface for any contract that wants to support safeTransfers from ERC721 asset contracts.
onERC721Received(address,address,uint256,bytes) :
Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} by `operator` from `from`, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
IERC1155Receiver :
_Available since v3.1._
onERC1155BatchReceived(address,address,uint256[],uint256[],bytes) :
Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. NOTE: To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector).
onERC1155Received(address,address,uint256,uint256,bytes) :
Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. NOTE: To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector).
supportsInterface(bytes4) :
Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
ECDSA :
Elliptic Curve Digital Signature Algorithm (ECDSA) operations. These functions can be used to verify that a message was signed by the holder of the private keys of a given address.
EIP712 :
https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in their contracts using a combination of `abi.encode` and `keccak256`. This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA ({_hashTypedDataV4}). The implementation of the domain separator was designed to be as efficient as possible while still properly updating the chain id to protect against replay attacks on an eventual fork of the chain. NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. _Available since v3.4._
constructor :
Initializes the domain separator and parameter caches. The meaning of `name` and `version` is specified in https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. - `version`: the current major version of the signing domain. NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart contract upgrade].
ERC165 :
Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ``` Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
supportsInterface(bytes4) :
See {IERC165-supportsInterface}.
SafeCast :
Wrappers over Solidity's uintXX/intXX casting operators with added overflow checks. Downcasting from uint256/int256 in Solidity does not revert on overflow. This can easily result in undesired exploitation or bugs, since developers usually assume that overflows raise errors. `SafeCast` restores this intuition by reverting the transaction when such an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always. Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing all math on `uint256` and `int256` and then downcasting.
DoubleEndedQueue :
A sequence of items with the ability to efficiently push and pop items (i.e. insert and remove) on both ends of the sequence (called front and back). Among other access patterns, it can be used to implement efficient LIFO and FIFO queues. Storage use is optimized, and all operations are O(1) constant time. This includes {clear}, given that the existing queue contents are left in storage. The struct is called `Bytes32Deque`. Other types can be cast to and from `bytes32`. This data structure can only be used in storage, and not in memory. ``` DoubleEndedQueue.Bytes32Deque queue; ``` _Available since v4.6._
Address :
Collection of functions related to the address type
Context :
Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.
Timers :
Tooling for timepoints, timers and delays
IGovernor :
Interface of the {Governor} core. _Available since v4.3._
ProposalCanceled(uint256) :
Emitted when a proposal is canceled.
ProposalCreated(uint256,address,address[],uint256[],string[],bytes[],uint256,uint256,string) :
Emitted when a proposal is created.
ProposalExecuted(uint256) :
Emitted when a proposal is executed.
VoteCast(address,uint256,uint8,uint256,string) :
Emitted when a vote is cast without params. Note: `support` values should be seen as buckets. Their interpretation depends on the voting module used.
VoteCastWithParams(address,uint256,uint8,uint256,string,bytes) :
Emitted when a vote is cast with params. Note: `support` values should be seen as buckets. Their interpretation depends on the voting module used. `params` are additional encoded parameters. Their intepepretation also depends on the voting module used.
COUNTING_MODE() :
A description of the possible `support` values for {castVote} and the way these votes are counted, meant to be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. There are 2 standard keys: `support` and `quorum`. - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. - `quorum=bravo` means that only For votes are counted towards quorum. - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique name that describes the behavior. For example: - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] JavaScript class.
castVote(uint256,uint8) :
Cast a vote Emits a {VoteCast} event.
castVoteBySig(uint256,uint8,uint8,bytes32,bytes32) :
Cast a vote using the user's cryptographic signature. Emits a {VoteCast} event.
castVoteWithReason(uint256,uint8,string) :
Cast a vote with a reason Emits a {VoteCast} event.
castVoteWithReasonAndParams(uint256,uint8,string,bytes) :
Cast a vote with a reason and additional encoded parameters Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params.
castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32) :
Cast a vote with a reason and additional encoded parameters using the user's cryptographic signature. Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params.
execute(address[],uint256[],bytes[],bytes32) :
Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the deadline to be reached. Emits a {ProposalExecuted} event. Note: some module can modify the requirements for execution, for example by adding an additional timelock.
getVotes(address,uint256) :
Voting power of an `account` at a specific `blockNumber`. Note: this can be implemented in a number of ways, for example by reading the delegated balance from one (or multiple), {ERC20Votes} tokens.
getVotesWithParams(address,uint256,bytes) :
Voting power of an `account` at a specific `blockNumber` given additional encoded parameters.
hasVoted(uint256,address) :
Returns weither `account` has cast a vote on `proposalId`.
hashProposal(address[],uint256[],bytes[],bytes32) :
Hashing function used to (re)build the proposal id from the proposal details..
name() :
Name of the governor instance (used in building the ERC712 domain separator).
proposalDeadline(uint256) :
Block number at which votes close. Votes close at the end of this block, so it is possible to cast a vote during this block.
proposalSnapshot(uint256) :
Block number used to retrieve user's votes and quorum. As per Compound's Comp and OpenZeppelin's ERC20Votes, the snapshot is performed at the end of this block. Hence, voting for this proposal starts at the beginning of the following block.
propose(address[],uint256[],bytes[],string) :
Create a new proposal. Vote start {IGovernor-votingDelay} blocks after the proposal is created and ends {IGovernor-votingPeriod} blocks after the voting starts. Emits a {ProposalCreated} event.
quorum(uint256) :
Minimum number of cast voted required for a proposal to be successful. Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}).
state(uint256) :
Current state of a proposal, following Compound's convention
supportsInterface(bytes4) :
Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
version() :
Version of the governor instance (used in building the ERC712 domain separator). Default: "1"
votingDelay() :
Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
votingPeriod() :
Delay, in number of blocks, between the vote start and vote ends. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.
IERC165 :
Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.
supportsInterface(bytes4) :
Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
Strings :
String operations.
IVotes :
Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts. _Available since v4.5._
DelegateChanged(address,address,address) :
Emitted when an account changes their delegate.
DelegateVotesChanged(address,uint256,uint256) :
Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
delegate(address) :
Delegates votes from the sender to `delegatee`.
delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32) :
Delegates votes from signer to `delegatee`.
delegates(address) :
Returns the delegate that `account` has chosen.
getPastTotalSupply(uint256) :
Returns the total supply of votes available at the end of a past block (`blockNumber`). NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes. Votes that have not been delegated are still part of total supply, even though they would not participate in a vote.
getPastVotes(address,uint256) :
Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).
getVotes(address) :
Returns the current amount of votes that `account` has.
Checkpoints :
This library defines the `History` struct, for checkpointing values as they change at different points in time, and later looking up past values by block number. See {Votes} as an example. To create a history of checkpoints define a variable type `Checkpoints.History` in your contract, and store a new checkpoint for the current transaction block using the {push} function. _Available since v4.5._
Math :
Standard math utilities missing in the Solidity language.
basic-dao.sol
Governor.sol
GovernorCountingSimple.sol
GovernorVotes.sol
GovernorVotesQuorumFraction.sol
IERC721Receiver.sol
IERC1155Receiver.sol
ECDSA.sol
draft-EIP712.sol
ERC165.sol
SafeCast.sol
DoubleEndedQueue.sol
Address.sol
Context.sol
Timers.sol
IGovernor.sol
IERC165.sol
Strings.sol
IVotes.sol
Checkpoints.sol
Math.sol