Environment
"dependencies": {
"@openzeppelin/contracts": "^3.4.0",
"@truffle/hdwallet-provider": "1.2.2",
"ganache-cli": "^6.12.2",
"mocha": "^8.3.2",
"solc": "^0.7.6",
"truffle": "^5.3.4",
"web3": "^1.3.5"
}
compilers: {
solc: {
version: "^0.7.6",
settings: {optimizer: {enabled: true, runs: 200}}
}
}
pragma solidity >0.6.0;
Details
I compile smart contract local by truffle compile
& get this error
not found: File import callback not supported import "../utils/Context.sol"
In smart contract implement ERC721PresetMinterPauserAutoId
// SPDX-License-Identifier: MIT
pragma solidity >0.6.0;
import "@openzeppelin/contracts/presets/ERC721PresetMinterPauserAutoId.sol";
contract MyProfileNFT is ERC721PresetMinterPauserAutoId {
constructor(
string memory name,
string memory symbol,
string memory baseUri
)
public
ERC721PresetMinterPauserAutoId(
name,
symbol,
baseUri
)
{}
}
pragma solidity >0.6.0;
import "@openzeppelin//contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./MyProfileNFT.sol";
contract MyProfile is Ownable, IERC721Receiver {
...
Full error
@openzeppelin//contracts/access/Ownable.sol:5:1: ParserError: Source "@openzeppelin//contracts/utils/Context.sol" not found: File import callback not supported
import "../utils/Context.sol";
^----------------------------^
I solved my error invalid import other contract path.
thank you.
1 Like
oriana
October 25, 2021, 12:48am
7
Hello everyone, I have the same problem:
How to solve this problem ? Thank you
Skyge
October 25, 2021, 1:01am
8
Hi, welcome!
Maybe you can try to remove the file node_modules
and then reinstall the dependencies. And try to compile the whole contracts, maybe there is something wrong with the plugin in the VS Code.
The solution is simple. Check out the solution here https://youtu.be/5qTdQNCMwk8 This video is helpful
The problem is with VS Code Solidity Extension. The video will help you solve it. https://youtu.be/5qTdQNCMwk8
1 Like