# ITokenFactory

Matt Stam (@mattstam)

ITokenFactory

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

https://blog.openzeppelin.com/workshop-recap-cheap-contract-deployment-through-clones/ Only CREATE2 / deterministic creation is supported, since in the Git Consensus Protocol the addresses should be predicted ahead of time.

# Methods

# createToken

function createToken(address govAddr, address minterAddr, string name, string symbol, uint256 _maxMintablePerHash, address[] owners, uint256[] values, bytes32 salt) external nonpayable returns (address instanceAddr)

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

# Parameters

Name Type Description
govAddr address Address of the corresponding governor contract. Recommended usage is use address prediction to create the Token first, then create the Governor with this Token's address as the tokenAddr parameter.
minterAddr address Address of the contract that will be able to mint new tokens. Should always be set to the Git Consensus contract's address.
name string Name of the token (e.g. "MyToken").
symbol string Symbol of the token (e.g. "MTK").
_maxMintablePerHash uint256 undefined
owners address[] Array of addresses to receive an initial distribution of tokens. MUST equal length of values.
values uint256[] Array of amounts of tokens to be given to each owner (in wei). The initial token supply will be equal to the sum of all values. MUST equal length of owners.
salt bytes32 The salt value used by CREATE2.

# Returns

Name Type Description
instanceAddr address The address of the newly created token clone.

# predictAddress

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

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

# Parameters

Name Type Description
salt bytes32 The salt value used by CREATE2.

# Returns

Name Type Description
instanceAddr address The address of the newly created token clone.

# Events

# TokenCreated

event TokenCreated(address instanceAddr, address creatorAddr, address govAddr, address minterAddr, string name, string symbol, uint256 maxMintablePerHash)

# Parameters

Name Type Description
instanceAddr address undefined
creatorAddr address undefined
govAddr address undefined
minterAddr address undefined
name string undefined
symbol string undefined
maxMintablePerHash uint256 undefined