#IGovernorFactory

Matt Stam (@mattstam)

IGovernorFactory

Clone factory for deploying token clones (minimal proxies of IGovernor).

https://blog.openzeppelin.com/workshop-recap-cheap-contract-deployment-through-clones/ Only CREATE2 / deterministic creation is supported, since in the Git Consensus Protocol onboarding, the addresses will always need to be be predicted ahead of time. The usual flow is: 1. Predict the address of the governor using GovernorFactory.predictAddress() 2. Deploy the token using TokenFactory.createToken(..., govAddr, ...) 3. Deploy the governor using GovernorFactory.createGovernor(..., tokenAddr, ...)

#Methods

#createGovernor

function createGovernor(address tokenAddr, string name, uint256 votingDelay, uint256 votingPeriod, uint256 proposalThreshold, uint256 quorumNumerator, bytes32 salt) external nonpayable returns (address instanceAddr)

Creates an IGovernor with an optional initial distribution. Uses CREATE2 so that the governor's address can be computed deterministically using predictAddress().

#Parameters

NameTypeDescription
tokenAddraddressThe ERC20 token that will be used for voting.
namestringName of the governor (e.g. "ExampleGovernor").
votingDelayuint256The number of blocks that must pass between a proposal being proposed and when it becomes executable (e.g. 1 = 1 block).
votingPerioduint256The number of blocks that voting is open for a proposal (e.g. 100800 = 2 weeks = 12/s per block).
proposalThresholduint256The minimum number of votes required for an account to create a proposal (e.g. 0 = anyone can create a proposal).
quorumNumeratoruint256The quorumNumerator/100 to give a percentage representing minimum number of votes out of the supply required to pass a proposal (e.g. 5 = 5%).
saltbytes32The salt value used by CREATE2.

#Returns

NameTypeDescription
instanceAddraddressThe address of the newly created governor clone.

#predictAddress

function predictAddress(bytes32 salt) external view returns (address instanceAddr)

Predicts the address of an IGovernor deployed using CREATE2 + salt value.

#Parameters

NameTypeDescription
saltbytes32The salt value used by CREATE2.

#Returns

NameTypeDescription
instanceAddraddressThe address of the newly created governor clone.

#Events

#GovernorCreated

event GovernorCreated(address instanceAddr, address creatorAddr, address tokenAddr, string name, uint256 votingDelay, uint256 votingPeriod, uint256 proposalThreshold, uint256 quorumNumerator)

#Parameters

NameTypeDescription
instanceAddraddressundefined
creatorAddraddressundefined
tokenAddraddressundefined
namestringundefined
votingDelayuint256undefined
votingPerioduint256undefined
proposalThresholduint256undefined
quorumNumeratoruint256undefined