Where is ERC20Mintable.sol in OpenZeppelin Contracts 3.0?

smalaichami asked on GitHub (https://github.com/OpenZeppelin/openzeppelin-contracts/issues/2092):

It looks like that ERC20Mintable.sol contract is moved or removed.
Could you please suggest what is the new parth for ERC20Mintable.sol ?

OpenZeppelin Contracts v3.0 has a beta release

The final v3.0 release is not yet finished

Roles contracts (such as MinterRole and PauserRole ) were removed: we’re redesigning our Access Control solution and will have a better version of these in the v3.0 release.


ERC20Mintable.sol is part of OpenZeppelin Contracts v2.5 which uses Solidity 0.5.
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20Mintable.sol

The master branch of the repo currently contains the work for the upcoming 3.0 release. For this release, we are removing the current role contracts, which includes MinterRole. Since we are removing this role, we are also removing the ERC20Mintable contract which used it.

There will be an alternative to ERC20Mintable and roles in 3.0, but we haven’t built it yet.

In the meantime, please continue using ERC20Mintable from the 2.5 release of Contracts, which can be found in the repository in the link that @abcoathup provided above.

3 Likes

6 posts were split to a new topic: Crowdsale contracts in OpenZeppelin Contracts 3.0?

Hey @frangio, v3 is out, but I can’t see the alternative for ERC20Mintable. I only found a ERC20Capped contract. Is this planned for a future version?

1 Like

Heya, I’ve had some similar issues fishing around, but if helpful, check out some of the OZ chunks I am using here which are blend of old/new (i’m still catching up lol)

2 Likes

Hi @PaulRBerg,

ERC20Capped.sol was rewritten and it doesn’t have a dependency on access control.

OpenZeppelin Contracts v3.x introduced ERC20PresetMinterPauser which includes minting and pausing functionality using access control:

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

The Preset contracts are opinionated, especially when it comes to access control.

Do you think there is still a need for an ERC20Mintable?
What access control should it have?

1 Like

Hi @Ro5s,

I suggest having a look at ERC20PresetMinterPauser in OpenZeppelin Contracts v3.0 depending where you are in the development cycle so you could update to Solidity 0.6 and OpenZeppelin Contracts 3.x.

I noticed that LexTokenFactory.sol has been flattened (I assume you used a flattener). I would recommend not flattening and only importing the OpenZeppelin Contracts for security and readability.

Note: Solidity 0.6.8 introduces SPDX license identifiers and the compiler will error if you have multiple license identifiers which you would get from flattening.

1 Like

Nah, ERC20PresetMinterPauser fits the bill well. Thanks, Andrew!

1 Like

V3 doesn’t include ERC20Mintable because the core contracts were made less opinionated: you get the internal _mint function in ERC20 and you can expose it as an external function however you want. This grew out of a feeling that basic contracts like v2’s ERC20Mintable can be inadequate when a project grows, and it’s also related to the fact that we introduced the more feature-complete AccessControl but we didn’t want to force everyone to use it. To balance this out, we introduced the “preset” contracts that piece together the different components in an opinionated way to provide ready to use contracts. So I’m glad to hear that worked for you.

Maybe we need to do a better job explaining this idea in the documentation. May I ask @PaulRBerg and @Ro5s in what places you tried to find this so that we can make sure this information is discoverable for others that may search in similar places?

3 Likes

@abcoathup Helpful links. I really like how OZ is showing more examples of ‘put together’ solidity for certain use cases ~~ lots of folks, like myself, are in team ‘copy pasta’

For LexTokenFactory I have the entire file there for my own silly purposes (I am actually a straight up “Remix” programmer, noob tendencies), but also, I remove some of the constructors for Roles that otherwise defaulted permissions to msg.sender (I like being able to set owner remotely from factory as option).

1 Like

Hi @Ro5s,

We can import OpenZeppelin Contracts via GitHub in Remix (see example: Deploy a simple ERC20 token in Remix). I find flattened contracts difficult to read and it isn’t clear when changes have been made (such as when you are modifying Roles).

I recommend checking out OpenZeppelin Contracts v3.0 Access Control

I think it’d be nice to have a reference to the new AccessControl contract and the “preset” model in the README of the ERC20 folder:

1 Like