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

**URL:** <https://forum.openzeppelin.com/t/truffle-imports-of-openzeppelin-contracts-fail-for-art-nft-factory-erc-1155-smart-contract/38201>\
**Category:** Smart Contracts\
**Tags:** truffle\
**Created:** [October 22, 2023, 3:44pm UTC](https://forum.openzeppelin.com/t/truffle-imports-of-openzeppelin-contracts-fail-for-art-nft-factory-erc-1155-smart-contract/38201 "2023-10-22T15:44:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LG102023](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/lg102023/32/19560_2.png) [@LG102023](https://forum.openzeppelin.com/u/LG102023)\
**Post date:** [October 22, 2023, 3:44pm UTC](https://forum.openzeppelin.com/t/truffle-imports-of-openzeppelin-contracts-fail-for-art-nft-factory-erc-1155-smart-contract/38201/1 "2023-10-22T15:44:16Z")

</div>

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](https://www.quicknode.com/guides/other-chains/polygon/how-to-create-and-deploy-a-factory-erc-1155-contract-on-polygon-using-truffle) 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.

 ![Screenshot-Truffle-Compilation-failed-NFT-Smart-Contract-ERC1155](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/3X/c/a/ca52031e085060fa8dd54524232be9ec144ec511.png)

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](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.

---

<div class="post-metadata">

**Author:** ![LG102023](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/lg102023/32/19560_2.png) [@LG102023](https://forum.openzeppelin.com/u/LG102023)\
**Post date:** [October 22, 2023, 4:56pm UTC](https://forum.openzeppelin.com/t/truffle-imports-of-openzeppelin-contracts-fail-for-art-nft-factory-erc-1155-smart-contract/38201/2 "2023-10-22T16:56:32Z")

</div>

I have started studying on OpenZeppelin about smart contracting and found this [hint](https://docs.openzeppelin.com/contracts/5.x/) 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.

---

<div class="post-metadata">

**Author:** ![EduardoMelo00](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/eduardomelo00/32/19539_2.png) [@EduardoMelo00](https://forum.openzeppelin.com/u/EduardoMelo00)\
**Post date:** [October 24, 2023, 3:31am UTC](https://forum.openzeppelin.com/t/truffle-imports-of-openzeppelin-contracts-fail-for-art-nft-factory-erc-1155-smart-contract/38201/3 "2023-10-24T03:31:21Z")

</div>

Hey fellow, which openzeppelin version are you using ?

---

<div class="post-metadata">

**Author:** ![EduardoMelo00](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/eduardomelo00/32/19539_2.png) [@EduardoMelo00](https://forum.openzeppelin.com/u/EduardoMelo00)\
**Post date:** [October 24, 2023, 3:39am UTC](https://forum.openzeppelin.com/t/truffle-imports-of-openzeppelin-contracts-fail-for-art-nft-factory-erc-1155-smart-contract/38201/4 "2023-10-24T03:39:25Z")

</div>

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:

[![](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/3X/f/5/f585e3063c95c03e1bb18ab3f7cecef79332d62e.jpeg "Intro to Foundry | The FASTEST Smart Contract Framework") ](https://www.youtube.com/watch?v=fNMfMxGxeag)

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.

---

<div class="post-metadata">

**Author:** ![LG102023](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/lg102023/32/19560_2.png) [@LG102023](https://forum.openzeppelin.com/u/LG102023)\
**Post date:** [October 24, 2023, 4:09pm UTC](https://forum.openzeppelin.com/t/truffle-imports-of-openzeppelin-contracts-fail-for-art-nft-factory-erc-1155-smart-contract/38201/5 "2023-10-24T16:09:02Z")

</div>

Hello, Eduardo !

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

```auto
npm install @openzeppelin/contracts

```

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

 ![Screenshot-Remix-Ethereum-Compilation-failed-NFT-Smart-Contract-ERC1155](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/3X/a/1/a1ed9ac9fd8a673854bb2597268cb652a6eb077b.png)  
 ![Screenshot-Truffle-Compilation-test-failed-NFT-Smart-Contract-ERC1155](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/3X/b/c/bc7a1aaef73e673887907530a5e23cebcc0fed89.png)

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)
