I'm trying to implement my own ERC20 using openzeppelin.

contract MyERC20 is ERC20 { ... }

And I want to make function from ERC20 pausable using openzeppelin Pausable contract. The question is - do I need to copy the whole function in MyERC20, for example:

function name() public view override whenPaused returns (string memory) {
    return _name;

Or there is the way to add modifier without copy of the function body?

1 Answer 1


Using Solidity's inheritance: https://docs.soliditylang.org/en/v0.8.12/contracts.html#inheritance when you inherit from a contract, it will implements it's functions (as long as they are public or internal) and modifiers.

As you can see in OZ's ERC20.sol, the name() function is public and it looks the exact same as what you wanna do. In this case, you don't need to implement a new name() function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.