# How to use OpenZepplin Contracts (with Solidity version ^0.6.0) in Truffle?

**URL:** <https://forum.openzeppelin.com/t/how-to-use-openzepplin-contracts-with-solidity-version-0-6-0-in-truffle/3722>\
**Category:** Contracts\
**Created:** [September 4, 2020, 3:04pm UTC](https://forum.openzeppelin.com/t/how-to-use-openzepplin-contracts-with-solidity-version-0-6-0-in-truffle/3722 "2020-09-04T15:04:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasa-develop](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/vasa-develop/32/1744_2.png) [@vasa-develop](https://forum.openzeppelin.com/u/vasa-develop)\
**Post date:** [September 4, 2020, 3:04pm UTC](https://forum.openzeppelin.com/t/how-to-use-openzepplin-contracts-with-solidity-version-0-6-0-in-truffle/3722/1 "2020-09-04T15:04:32Z")

</div>

I’m encountering an error while compiling a contract (with version \>=0.4.21 \<0.7.0) which imports the following contracts.

```auto
@openzeppelin/contracts/token/ERC721/ERC721.sol
@openzeppelin/contracts/utils/Counters.sol

```

which both have a solidity version (^0.6.0).

Here is the [full contract used](https://github.com/filecoin-shipyard/meme-nft-token/blob/master/contracts/MemeMarketplace.sol).

Here is the error while `truffle compile`:

```auto
Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify "pragma solidity ^0.6.0"

```

**💻 Environment**  
`truffle`: 5.1.43  
`solc`: 0.5.16  
`@openzeppelin/contracts`: 3.1.0

I have tried the [following approach to fix the issue](https://stackoverflow.com/a/55643945/7196169). Is this an issue from truffle or am I missing something here?

---

<div class="post-metadata">

**Author:** ![DragonLord](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/dragonlord/32/2966_2.png) [@DragonLord](https://forum.openzeppelin.com/u/DragonLord)\
**Post date:** [September 4, 2020, 6:55pm UTC](https://forum.openzeppelin.com/t/how-to-use-openzepplin-contracts-with-solidity-version-0-6-0-in-truffle/3722/2 "2020-09-04T18:55:50Z")

</div>

Hi @vasa-develop, go to your truffle-config.js file and change the compiler version to use 0.6.0

---

<div class="post-metadata">

**Author:** ![DragonLord](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/dragonlord/32/2966_2.png) [@DragonLord](https://forum.openzeppelin.com/u/DragonLord)\
**Post date:** [September 4, 2020, 6:58pm UTC](https://forum.openzeppelin.com/t/how-to-use-openzepplin-contracts-with-solidity-version-0-6-0-in-truffle/3722/3 "2020-09-04T18:58:36Z")

</div>

```
compilers: {
solc: {
  version: "0.6.0", // Fetch exact version from solc-bin (default: truffle's version)
},
```

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [September 4, 2020, 10:26pm UTC](https://forum.openzeppelin.com/t/how-to-use-openzepplin-contracts-with-solidity-version-0-6-0-in-truffle/3722/4 "2020-09-04T22:26:35Z")

</div>

Thanks @DragonLord,

I believe it will actually need to be 0.6.2 or above as one of the dependencies needs 0.6.2.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [September 7, 2020, 3:00am UTC](https://forum.openzeppelin.com/t/how-to-use-openzepplin-contracts-with-solidity-version-0-6-0-in-truffle/3722/5 "2020-09-07T03:00:21Z")

</div>

Hi @vasa-develop,

Just wanted to follow up.  
As you are using OpenZeppelin Contracts v3.x, the pragma for your contract should be ^0.6.2 as an earlier version of the compiler won’t be able to compile the contract.

With your imports `import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol";` you should be able to have these as `import "@openzeppelin/contracts/token/ERC721/ERC721.sol";`

There currently isn’t any access control on minting, which means anyone can mint a token.  
[https://github.com/filecoin-shipyard/meme-nft-token/blob/master/contracts/MemeMarketplace.sol#L15](https://github.com/filecoin-shipyard/meme-nft-token/blob/master/contracts/MemeMarketplace.sol#L15)

To see [AccessControl](https://docs.openzeppelin.com/contracts/3.x/access-control#role-based-access-control) in action see the ERC721PresetMinterPauserAutoId contract:

> <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/presets/ERC721PresetMinterPauserAutoId.sol#L63>

---

<div class="post-metadata">

**Author:** ![vasa-develop](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/vasa-develop/32/1744_2.png) [@vasa-develop](https://forum.openzeppelin.com/u/vasa-develop)\
**Post date:** [September 7, 2020, 8:57am UTC](https://forum.openzeppelin.com/t/how-to-use-openzepplin-contracts-with-solidity-version-0-6-0-in-truffle/3722/6 "2020-09-07T08:57:18Z")

</div>

> [@abcoathup](#):
>
> y isn’t any access control

Thanks for suggestions @abcoathup @DragonLord 🙂
