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 aother accounts

Modifiers

constructor(string name, string symbol) public

Grants DEFAULT_ADMIN_ROLE, MINTER_ROLE and PAUSER_ROLE to the account that deploys the contract.

mint(address to, uint256 amount) public

Creates amount new tokens for to.

Requirements:

  • the caller must have the MINTER_ROLE.

pause() public

Pauses all token transfers.

Requirements:

  • the caller must have the PAUSER_ROLE.

unpause() public

Unpauses all token transfers.

Requirements:

  • the caller must have the PAUSER_ROLE.

_beforeTokenTransfer(address from, address to, uint256 amount) internal

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 aother accounts

Modifiers

constructor(string name, string symbol, string baseURI) public

Grants DEFAULT_ADMIN_ROLE and MINTER_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.

Requirements:

  • the caller must have the MINTER_ROLE.

pause() public

Pauses all token transfers.

Requirements:

  • the caller must have the PAUSER_ROLE.

unpause() public

Unpauses all token transfers.

Requirements:

  • the caller must have the PAUSER_ROLE.

_beforeTokenTransfer(address from, address to, uint256 tokenId) internal