1

i have copied a contract from openzappline. but when i compile it on remix it gives me the error....that utils/context.sol is not found.

here is the import

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;

mapping (address => mapping (address => uint256)) private _allowances;

uint256 private _totalSupply;

string private _name;
string private _symbol;
FSO
  • 89
  • 1
  • 7

3 Answers3

2

import "@openzeppelin/contracts/utils/Context.sol";

this should help

The file that's being called is from the root directory, not inside the ERC20 files.

HighXTC
  • 21
  • 3
1
import "../../utils/Context.sol";

This line tries to import the file Context.sol from "utils" folder located "two folders up" relative to the folder where your ERC20 contract is located.

Easiest solution in this context (where no other contract imports the Context.sol) is to copy-paste the Context.sol to a reachable location (e.g. to the same folder as your ERC20) and change the import path (e.g. to import "./Context.sol").

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • when i delete context.sol it shows same error for this line import "./extensions/IERC20Metadata.sol"; – FSO Apr 17 '21 at 11:24
  • Then you don't have the `IERC20Metadata.sol` file in folder `extensions` relative to your root folder. Follow the same guide from my answer but with the `IERC20Metadata.sol` file – Petr Hejda Apr 17 '21 at 11:33
  • so i have to put this file in remix within same folder? – FSO Apr 17 '21 at 11:40
  • @FSO That's correct. Don't forget to change the imports so that they point to the same folder as well. – Petr Hejda Apr 17 '21 at 11:46
  • where to find ec20detailed? – FSO Apr 17 '21 at 12:06
  • @FSO Tip: Search the OpenZeppelin's [GitHub](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC20) – Petr Hejda Apr 17 '21 at 12:08
0

If youre importing an openzeppelin contract ex:
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

make sure to include a GPL-3 licence

// SPDX-License-Identifier: GPL-3.0

this helped me to get the npm deps in remix