Truffle Imports of OpenZeppelin Contracts fail for art NFT (Factory ERC 1155 smart contract)

Hello everybody. I am new here ... so I hope its the right place. I am not a professoinal developer with coding skills. Mostly I follow tutorials, e.g. I know how to install Linux (ubuntu) or setup a server for wordpress. But thats it. No coding skills as such. Tks in advance for your patiency.

I target at creating an independent own smart contract for art NFTs, which I can trade with MetaMask wallet (Matic token / Polygon Mainnetwork) on OpenSea, NFTify and Rarible (the three leading NFT market places).

I followed the instructions on Quicknode to setup a smart contract using Truffle. The fully setup is following:

Windows 10 on Windows NT Server

Truffle v5.11.5 (core: 5.11.5)
Ganache v7.9.1
Solidity - 0.8.20 (solc-js), downgraded from 0.8.40 for import of different *.sol contracts
Node v18.18.2
Web3.js v1.10.0
npm (v10.2.1)
git (v2.42.0.windows.2)
Ascii Text editor (Notepad++ v8.5.8)
MetaMask (Browser extensoin in Google Chrome / Firefox) with Poylgon Testnet (Mumbai)
For uploading the meta data and images to mint: IPFS account and nft.storage .

The smart contract is being programmed with a Polygon endpoint, deliverd by quicknodes, and an API key for Poylgon Testnet (Mumbai) via Polygonscan. As for now I like to do first a fully test of the data workflow.

I managed it to follow the Quicknode tutorial to the point for the "truffle test" and "truffle compile", but here I get an error message, see screenshot of the terminal.

The original import code in the file ERC1555Token.sol you can find in the Quicknode link (Rec.: As new user in this forum, I am only allowed to post two links).

Its not working at all as the error message says:

ParserError: Source "@openzeppelin/contracts/token/ERC1155/ERC1155.sol" not found
--> project:/contracts/ERC1155Token.sol:6:1:
|
6 | import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

,ParserError: Source "@openzeppelin/contracts/access/Ownable.sol" not found
--> project:/contracts/ERC1155Token.sol:7:1:
|
7 | import "@openzeppelin/contracts/access/Ownable.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

,ParserError: Source "@openzeppelin/contracts/utils/Strings.sol" not found
--> project:/contracts/ERC1155Token.sol:8:1:
|
8 | import "@openzeppelin/contracts/utils/Strings.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Compilation failed. See above.
Truffle v5.11.5 (core: 5.11.5)

I suppose its because the OpenZeppelin structure on Github has changed
from ..... openzepelin/contracts/... to openzeppelin/openzeppelin-contracts/...

I already tried three (3) different versions of import codes, but all failed, too:

// import "github/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol";

// import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol";

// import "github/OpenZeppelin/openzeppelin/contracts/contracts/token/ERC1155/ERC1155.sol";

I would thank you for some conrete hints how to solve this problem. Tks in advance.

I have started studying on OpenZeppelin about smart contracting and found this hint in the Docs section, which might relate to my question. - But I am not sure , if it fits ?

Anybody here experienced with ?

1.) I have found the remappings.txt file in the sub folder of nodes: C:\Users\myNFTProject\node_modules\openzeppelin-solidity...

... and I might have to change the content of this txt file as adviced to:

Add @openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/

But I dont get the other two hints:

2.1.) I have already OpenZeppelin contracts in the sub folder
C:\Users\myNFTProject\node_modules\openzeppelin-solidity\contracts

Is this command required to update the whole folder as adviced (see upper link)?
npm install @openzeppelin/contracts

Or is it obsolete ? (Rec.: I have installed Truffle and Node.js yesterday, I suppose its updated, isnt ?)

Do I have to start this command in the windows terminal after I changed the path to the project directory C:\Users\mynftproject... ?? I dont get where to store the content by this installation ?

2.2.) Which tool for the forging command ? Can I use "git" as I have installed it ?

forge install OpenZeppelin/openzeppelin-contracts

And same question here: Which directory I have to use to start the command ?

Tks for your spuport.

Hey fellow, which openzeppelin version are you using ?

Let's start from scratch my friend, it's a little mess haha, you are trying to use foundry mix with truffle.

First i recommend you to choose between hardhat or foundry as a solidity framework.

Once this is done, you can start working on the right way.

btw: forge commands is foundry related.

I recommend you to watch this video:

just one more thing, pay attention on the openzeppelin version because by default forge install will install the last openzeppelin version (5.0) and in this version something were change, for example:

the String.sol was removed.

Hello, Eduardo !

Tks for your time and support. The problem is gone. I used the command

npm install @openzeppelin/contracts

And the problem is gone. But now There is another issue as the Compiling test shows. See screenshots:


I followed the tutorial on quicknode (see upper link in first post) to setup the smart contract ... but something went wrong. It seems the code is defect.

The tutorial at Quicknode let import three OpenZeppelin contracts into the file ERC1155Token.sol:

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

The import worked itself. Either Truffle test or Truffle Compile command or the compiling test in Remix.Ethereum show the same problem, see following:

TypeError: No arguments passed to the base constructor. Specify the arguments or mark "ERC1155Token" as abstract.
--> project:/contracts/ERC1155Token.sol:10:1:
|
10 | contract ERC1155Token is ERC1155, Ownable {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Base constructor parameters:
--> @openzeppelin/contracts/access/Ownable.sol:38:16:
|
38 | constructor(address initialOwner) {
| ^^^^^^^^^^^^^^^^^^^^^^

Compilation failed. See above.

My own system is:

Windows 10 on Windows NT Server (hosted via AWS Amazon)

Truffle v5.11.5 (core: 5.11.5)
Ganache v7.9.1
Solidity - 0.8.20 (solc-js), downgraded from 0.8.40 for import of different *.sol contracts
Node v18.18.2
Web3.js v1.10.0
npm (v10.2.1)
git (v2.42.0.windows.2)
Ascii Text editor (Notepad++ v8.5.8)