Presets
This document is better viewed at https://docs.openzeppelin.com/contracts/api/presets |
These contracts integrate different Ethereum standards (ERCs) with custom extensions and modules, showcasing common configurations that are ready to deploy without having to write any Solidity code.
They can be used as-is for quick prototyping and testing, but are also suitable for production environments.
Intermediate and advanced users can use these as starting points when writing their own contracts, extending them with custom functionality as they see fit. |
Tokens
ERC20PresetMinterPauser
ERC20
token, including:
-
ability for holders to burn (destroy) their tokens
-
a minter role that allows for token minting (creation)
-
a pauser role that allows to stop all token transfers
This contract uses AccessControl
to lock permissioned functions using the
different roles - head to its documentation for details.
The account that deploys the contract will be granted the minter and pauser roles, as well as the default admin role, which will let it grant both minter and pauser roles to other accounts.
constructor(string name, string symbol)
public
Grants DEFAULT_ADMIN_ROLE
, MINTER_ROLE
and PAUSER_ROLE
to the
account that deploys the contract.
See ERC20.constructor
.
mint(address to, uint256 amount)
public
Creates amount
new tokens for to
.
See ERC20._mint
.
Requirements:
-
the caller must have the
MINTER_ROLE
.
pause()
public
Pauses all token transfers.
See ERC20Pausable
and Pausable._pause
.
Requirements:
-
the caller must have the
PAUSER_ROLE
.
unpause()
public
Unpauses all token transfers.
See ERC20Pausable
and Pausable._unpause
.
Requirements:
-
the caller must have the
PAUSER_ROLE
.
ERC721PresetMinterPauserAutoId
ERC721
token, including:
-
ability for holders to burn (destroy) their tokens
-
a minter role that allows for token minting (creation)
-
a pauser role that allows to stop all token transfers
-
token ID and URI autogeneration
This contract uses AccessControl
to lock permissioned functions using the
different roles - head to its documentation for details.
The account that deploys the contract will be granted the minter and pauser roles, as well as the default admin role, which will let it grant both minter and pauser roles to other accounts.
constructor(string name, string symbol, string baseURI)
public
Grants DEFAULT_ADMIN_ROLE
, MINTER_ROLE
and PAUSER_ROLE
to the
account that deploys the contract.
Token URIs will be autogenerated based on baseURI
and their token IDs.
See ERC721.tokenURI
.
mint(address to)
public
Creates a new token for to
. Its token ID will be automatically
assigned (and available on the emitted IERC721.Transfer
event), and the token
URI autogenerated based on the base URI passed at construction.
See ERC721._mint
.
Requirements:
-
the caller must have the
MINTER_ROLE
.
pause()
public
Pauses all token transfers.
See ERC721Pausable
and Pausable._pause
.
Requirements:
-
the caller must have the
PAUSER_ROLE
.
unpause()
public
Unpauses all token transfers.
See ERC721Pausable
and Pausable._unpause
.
Requirements:
-
the caller must have the
PAUSER_ROLE
.
ERC1155PresetMinterPauser
ERC1155
token, including:
-
ability for holders to burn (destroy) their tokens
-
a minter role that allows for token minting (creation)
-
a pauser role that allows to stop all token transfers
This contract uses AccessControl
to lock permissioned functions using the
different roles - head to its documentation for details.
The account that deploys the contract will be granted the minter and pauser roles, as well as the default admin role, which will let it grant both minter and pauser roles to other accounts.
constructor(string uri)
public
Grants DEFAULT_ADMIN_ROLE
, MINTER_ROLE
, and PAUSER_ROLE
to the account that
deploys the contract.
mint(address to, uint256 id, uint256 amount, bytes data)
public
Creates amount
new tokens for to
, of token type id
.
See ERC1155._mint
.
Requirements:
-
the caller must have the
MINTER_ROLE
.
pause()
public
Pauses all token transfers.
See ERC1155Pausable
and Pausable._pause
.
Requirements:
-
the caller must have the
PAUSER_ROLE
.
unpause()
public
Unpauses all token transfers.
See ERC1155Pausable
and Pausable._unpause
.
Requirements:
-
the caller must have the
PAUSER_ROLE
.
ERC20PresetFixedSupply
ERC20
token, including:
-
Preminted initial supply
-
Ability for holders to burn (destroy) their tokens
-
No access control mechanism (for minting/pausing) and hence no governance
This contract uses ERC20Burnable
to include burn capabilities - head to
its documentation for details.
Available since v3.4.
constructor(string name, string symbol, uint256 initialSupply, address owner)
public
Mints initialSupply
amount of token and transfers them to owner
.
See ERC20.constructor
.
ERC777PresetFixedSupply
ERC777
token, including:
-
Preminted initial supply
-
No access control mechanism (for minting/pausing) and hence no governance
Available since v3.4.
constructor(string name, string symbol, address[] defaultOperators, uint256 initialSupply, address owner)
public
Mints initialSupply
amount of token and transfers them to owner
.
See ERC777.constructor
.