Pragma solidity 0.5.7 for contract

I want to compile contracts.
Contracts have version pragma solidity 0.5.7;

Contracts use
openzeppelin-solidity / contracts / ownership / Ownable.sol
openzeppelin-solidity / contracts / math / SafeMath.sol
openzeppelin-solidity / contracts / token / ERC20 / ERC20Burnable.sol
openzeppelin-solidity / contracts / utils / Address.sol

These contracts have version
pragma solidity> = 0.6.0 <0.8.0;

truffle settings

compilers: {
    solc: {
      version: "0.5.7", // Fetch exact version from solc-bin (default: truffle's version)
      docker: false, // Use "0.5.1" you've installed locally with docker (default: false)
      settings: {// See the solidity docs for advice about optimization and evmVersion
        optimizer: {
          enabled: false,
          runs: 200
        },
        evmVersion: "byzantium"
      }
    }
  }

How do I specify the correct version for solc?
Or how can I get contracts with
pragma solidity 0.5.7; for openzeppelin-solidity

/home/zb/cLion/system/go/src/github.com/OpenBazaar/smart-contracts/contracts/registry/ContractManager.sol:5:1: ParserError: Source "openzeppelin-solidity/contracts/ownership/Ownable.sol" not found: File import callback not supported
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
^-------------------------------------------------------------^
,/home/zb/cLion/system/go/src/github.com/OpenBazaar/smart-contracts/contracts/rewards/OBRewards.sol:6:1: ParserError: Source "openzeppelin-solidity/contracts/ownership/Ownable.sol" not found: File import callback not supported
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
^-------------------------------------------------------------^
,openzeppelin-solidity/contracts/math/SafeMath.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.5.7+commit.6da8b019.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity >=0.6.0 <0.8.0;
^-----------------------------^
,openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.5.7+commit.6da8b019.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity >=0.6.0 <0.8.0;
^-----------------------------^
,openzeppelin-solidity/contracts/utils/Address.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.5.7+commit.6da8b019.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity >=0.6.2 <0.8.0;
^-----------------------------^

Error: Truffle is currently using solc =0.5.7 <0.8.0, but one or more of your contracts specify "pragma solidity >=0.6.0 <0.8.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.
Truffle v5.3.7 (core: 5.3.7)
Node v16.1.0

Either downgrade openzeppeling contracts to previous version which works with your compiler version or upgrade your contract to meet 0.6.0 requirements. I was struggling with the same thing and you just have to have all the contracts meeting the same compiler version, or similar.

1 Like