'not found utils/context.sol when i import from openzepplin
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;
Solution 1:[1]
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.
Solution 2:[2]
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"
).
Solution 3:[3]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | HighXTC |
Solution 2 | Petr Hejda |
Solution 3 | Konstantin Smirnov |