4

I have created a node.js project, within which I have created a truffle directory and initialised its project. I have installed the openzeppelin (npm install @openzeppelin/contracts) library in this truffle project directory, but nothing appears to have been installed, although I did not received any error during the install process. The import statement in my project displays the error hereafter:

import "@openzeppelin/contracts/token/ERC721/ERC721Full.sol";

Source "@openzeppelin/contracts/token/ERC721/ERC721Full.sol" not found: File import callback not supported

Thank you. J

2 Answers 2

3

If you run npm uninstall @openzeppelin/contracts and then npm install @openzeppelin/[email protected], then retry the import, then it should work.

Also, check your truffle-config.js file and see if the root directory is configured properly to find your node_modules folder properly.

3
  • Thank you Max for your comment. I have run the 2 commands above in order to install the proper version of openzeppelin. However, I am not finding any example on how to configure the truffle-config.js file so that the node_modules folder can be properly found.
    – JF0001
    Commented Oct 20, 2020 at 1:15
  • 1
    Add this to your contracts_build_directory: path.join(__dirname, "insert path to your contracts folder here"), ``` const path = require("path"); module.exports = { // See <truffleframework.com/docs/advanced/configuration> // to customize your Truffle configuration! contracts_build_directory: path.join(__dirname, "./contracts"), compilers: { solc: { version: 'yoursolcversionhere' } }, networks:{ .... };```
    – Max
    Commented Oct 20, 2020 at 1:51
  • Thank you very much for your help and time Max. Actually, it appears that my project hadn't been initialised properly for some reason. After running npm init again, everything is working properly.
    – JF0001
    Commented Oct 20, 2020 at 2:43
2

That's because ERC721Full.sol no longer exists, as you can see in the Github repository. From the latest update (v3.0) of the OpenZeppelin contracts, you can read the following:

ERC20 and ERC721 were simplified and streamlined, including all optional parts of the standard by default, and simplifying some of our own custom extensions.

[...]

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.

You should use ERC721.sol, which includes the parts of ERC721Full.sol:

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

If you want to install a specific version (example: v2.3.0):

npm install @openzeppelin/[email protected]
5
  • Thank you Alberto for your comment. However, the file does exists at the following URL, and it is working properly in Remix. github.com/OpenZeppelin/openzeppelin-contracts/tree/v2.3.0/… I believe that there is a problem with my install.
    – JF0001
    Commented Oct 19, 2020 at 21:49
  • @JF0001 Yes, but this is the version v2.3 of the contracts. I supposed that you wanted to use the latest version because you didn't use a specific version in your npm command.
    – alberto
    Commented Oct 19, 2020 at 21:53
  • Thank you again Alberto. Understood, but even if I specify the URL that you have provided, I am still obtaining the same issue. I definitely believe that there is a problem with my install. However, I am not able to find any command online that I can use to see the version of openzeppelin installed.
    – JF0001
    Commented Oct 19, 2020 at 21:58
  • 1
    You can check your package.json file, for example: $ cat package.json
    – alberto
    Commented Oct 19, 2020 at 22:16
  • Thank you very much for your help and time Alberto. Actually, it appears that my project hadn't been initialised properly for some reason. After running npm init again, everything is working properly.
    – JF0001
    Commented Oct 20, 2020 at 2:44

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.