I am trying to use OpenZeppelin's ERC-721 from the example on their website, using truffle.
In my truffle I have changed the solc compiler version to 0.6.0.
compilers: {
solc: {
version: "^0.6.0", // Fetch exact version from solc-bin (default: truffle's version)
}
}
}
When I try to "truffle" compile, I get the following errors:
CompileError: @openzeppelin/contracts/math/SafeMath.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.12+commit.27d51765.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version pragma solidity ^0.5.0; ^---------------------^ ,@openzeppelin/contracts/token/ERC20/ERC20.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.12+commit.27d51765.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version pragma solidity ^0.5.0; ^---------------------^ ,@openzeppelin/contracts/token/ERC721/ERC721.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.12+commit.27d51765.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version pragma solidity ^0.5.0; ^---------------------^
Error: Truffle is currently using solc ^0.6.0, but one or more of your contracts specify "pragma solidity ^0.5.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.)
What I am not understanding is, if the underlying safemath implementations need older solc compiler, and the ERC-721 needs a newer solc compiler, How can anyone compile them? Why are the solc 0.6.0 not able to compile the older 0.5.0 solidity code?
Can someone please explain how to resolve such circular dependencies?
Environment
Truffle v5.1.58 (core: 5.1.58)
Solidity - ^0.5.0 (solc-js)