Truffle is currently using solc 0.7.0, but one or more of your contracts specify "pragma solidity ^0.6.0"

I write pragma solidity ^0.7.0 and it give me mistake

Compiling your contracts...
===========================
> Compiling ./contracts/ICO.sol
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Token.sol
> Compiling @openzeppelin/contracts/math/SafeMath.sol
> Compiling @openzeppelin/contracts/token/ERC20/ERC20.sol
> Compiling @openzeppelin/contracts/token/ERC20/IERC20.sol

CompileError: @openzeppelin/contracts/math/SafeMath.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.7.0+commit.9e61f92b.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.6.0;
^---------------------^
,@openzeppelin/contracts/token/ERC20/ERC20.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.7.0+commit.9e61f92b.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.6.0;
^---------------------^
,@openzeppelin/contracts/token/ERC20/IERC20.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.7.0+commit.9e61f92b.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.6.0;
^---------------------^

Error: Truffle is currently using solc 0.7.0, but one or more of your contracts specify "pragma solidity ^0.6.0".
Please update your truffle config or pragma statement(s).
(See https://trufflesuite.com/docs/truffle/reference/configuration#compiler-configuration for information on
configuring Truffle to use a specific solc compiler version.)

Compilation failed. See above.
    at run (/home/asven/.nvm/versions/node/v14.15.0/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/run.js:51:1)
    at Object.sourcesWithDependencies (/home/asven/.nvm/versions/node/v14.15.0/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/index.js:107:49)
    at necessary (/home/asven/.nvm/versions/node/v14.15.0/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/index.js:69:1)
    at /home/asven/.nvm/versions/node/v14.15.0/lib/node_modules/truffle/build/webpack:/packages/workflow-compile/index.js:38:1
    at async Promise.all (index 0)
    at compile (/home/asven/.nvm/versions/node/v14.15.0/lib/node_modules/truffle/build/webpack:/packages/workflow-compile/index.js:28:1)
    at Object.compile (/home/asven/.nvm/versions/node/v14.15.0/lib/node_modules/truffle/build/webpack:/packages/workflow-compile/index.js:67:38)
Truffle v5.1.54 (core: 5.1.54)
Node v14.15.0
in truffle-confige.js  solc ^0.7.0
1 Like

Hi @asven-2020,

The details of your post were hidden in comments, I have edited your post.

If you want to use OpenZeppelin Contracts 3.x with Solidity 0.7 you can install the Solidity 0.7 variant:

npm install @openzeppelin/contracts@solc-0.7

See: OpenZeppelin Contracts 3.2

Hallo abcoathup,

Problem that 3.x havent crouwdsale, all it in openzeppelin-solidity 2.x cant find better version in this case i must do token in solc 0.5.6
or may be you can recommend better

1 Like

Hi @asven-2020,

If you want to use OpenZeppelin Contracts 2.x then you can install with:

npm install @openzeppelin/contracts@2.5.1

OpenZeppelin Contracts 2.x uses Solidity 0.5.

For crowdsale documentation: https://docs.openzeppelin.com/contracts/2.x/crowdsales

You could have one project for your token and one project for your crowdsale, but it may be simpler to just use OpenZeppelin Contracts 2.x for both.

ok thank you

but if i also take this token to another place I havent problem in version

1 Like