ERC20Detailed.sol not found in @openzeppelin/contracts/token/ERC20 on GitHub

:computer: Environment

I’m using Truffle v5.1.32


After installing openzepplin package from npm, I tried importing the above contracts but it reverted with TypeError in the terminal complaining about import “@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol” file.
Error: Could not find @openzeppelin/contracts/token/ERC20/ERC20Detailed.sol from any sources. Could there an update on openzepplin repo removing or renaming the ERC20Detailed.sol file?

:1234: Code to reproduce

pragma solidity ^0.5.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";

contract Dai is ERC20, ERC20Detailed {
    constructor() public ERC20Detailed("Dai Stablecoin", "DAI", 18) {
1 Like

Hi @Sam-Devs,

Welcome to the community :wave:

I assume you are looking at a tutorial or guide which uses OpenZeppelin Contracts v2.x whilst installing OpenZeppelin Contracts v3.x.

The latest version of OpenZeppelin Contracts is v3.1.0

See the release notes for v3.0.0

Migrating From OpenZeppelin Contracts v2.5

If you’re using the ERC20 or ERC721 tokens however, you’ll have to remove all references to optional extensions ( ERC20Detailed , ERC721Enumerable , etc.) - these have been included in the base contracts.

A Simple Token using OpenZeppelin Contracts v3.x is as follows:


// contracts/SimpleToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
contract SimpleToken is ERC20 {

     * @dev Constructor that gives msg.sender all of existing tokens.
    constructor () public ERC20("Simple Token", "SIM") {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));

Alternatively you can install OpenZeppelin Contracts v2.x

$ npm install @openzeppelin/contracts@2.5.1

Thank you, I had to install @openzeppelin/contracts@2.4.0 to fix this problem.

1 Like

Hi @Sam-Devs,

Glad you were able to resolve.

If you were following a tutorial, do you mind sharing the link?