1

when I try to compile my contract I see errors like this :

DemirelToken.sol

https://eksiup.com/p/4z49413damc3

here's the code :

    pragma solidity ^0.5.0;

import "node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";

contract DemirelToken is ERC20, ERC20Detailed {
    constructor(uint256 initialSupply) ERC20Detailed("Gold", "GLD", 18) public {
        _mint(msg.sender, initialSupply);
    }
}

I get errors like this:

node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol:3:1: ParserError: Source "node_modules/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol" not found: File import callback not supported import "./IERC20.sol"; ^--------------------^ ,node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol:4:1: ParserError: Source "node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol" not found: File import callback not supported import "../../math/SafeMath.sol"; ^-------------------------------^ ,node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol:3:1: ParserError: Source "node_modules/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol" not found: File import callback not supported import "./IERC20.sol";

2 Answers 2

1

You need to fix the path in the imports:

pragma solidity ^0.5.0;

import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";

contract DemirelToken is ERC20, ERC20Detailed {
    constructor(uint256 initialSupply) ERC20Detailed("Gold", "GLD", 18) public {
        _mint(msg.sender, initialSupply);
    }
}
2

Ensure you have installed openzeppelin-solidity in your project

npm install openzeppelin-solidity

Your imports are then as follows:

pragma solidity ^0.5.0;

import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";

contract DemirelToken is ERC20, ERC20Detailed {
    constructor(uint256 initialSupply) ERC20Detailed("Gold", "GLD", 18) public {
        _mint(msg.sender, initialSupply);
    }
}

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.