I'm using the contracts OpenZeppelin provides, but I don't understand why there is 2 version of the same one. Why is there an I version vs non-I?

1 Answer 1


Short answer:

  • IERC is the Interface for the token contract.
  • ERC is the implementation of the token contract.

Interfaces are like blueprints, to make sure a Class (in our case, a Contract) implementation has the right methods, with the right method visibility, parameters and return values.

A method on IERC file:

function balanceOf(address account) external view returns (uint256);

It does not hold code, but has some valuable information:

  • it has name balanceOf.
  • it takes one parameter of type address, and name account.
  • it is a "read only" method, based on view.
  • it returns a uint256 value.
  • it DOES NOT have code.

The same method on the ERC file:

    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
  • it HAS code.

Note that the ERC20 file imports the IERC20 file and defines that on line 33: ERC20 is a IERC20. In other words: "ERC20 should implement methods from interface IERC20".

  • 1
    Thank you so much for your detailed explanation! If I'm creating my own NFT token, should I inherit from the implementation or the interface?
    – Adrian D.
    Commented May 24, 2021 at 20:08
  • 1
    from the interface, definitely.
    – FRAGA
    Commented May 27, 2021 at 1:06
  • It looks like Interfaces are to Implementations what header .h files are to .c files in C.
    – Bebs V
    Commented May 21, 2022 at 9:47

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.