0

My Contract has pragma solidity ^0.8.0; but I am using this library to be able to split strings that uses pragma solidity ^0.5.0;.

Changing this line alone wont fix the issue, it will create new ones (other compilation errors).

What can I do?

[1] Compiling your contracts...
[1] ===========================
[1] > Compiling @openzeppelin\contracts\access\Ownable.sol
[1] > Compiling @openzeppelin\contracts\token\ERC721\ERC721.sol
[1] > Compiling @openzeppelin\contracts\token\ERC721\IERC721.sol
[1] > Compiling @openzeppelin\contracts\token\ERC721\IERC721Receiver.sol
[1] > Compiling @openzeppelin\contracts\token\ERC721\extensions\IERC721Metadata.sol
[1] > Compiling @openzeppelin\contracts\utils\Address.sol
[1] > Compiling @openzeppelin\contracts\utils\Context.sol
[1] > Compiling @openzeppelin\contracts\utils\Strings.sol
[1] > Compiling @openzeppelin\contracts\utils\introspection\ERC165.sol
[1] > Compiling @openzeppelin\contracts\utils\introspection\IERC165.sol
[1] > Compiling .\contracts\MyContract.sol
[1] > Compiling solidity-util\lib\Strings.sol
[1] 
[1] ParserError: Source file requires different compiler version (current compiler is 0.8.7+commit.e28d00a7.Emscripten.clang) - note that nightly builds are considered 
to be strictly less than the released version
[1]  --> solidity-util/lib/Strings.sol:1:1:
[1]   |
[1] 1 | pragma solidity ^0.5.0;
[1]   | ^^^^^^^^^^^^^^^^^^^^^^^
[1]
[1]
[1] Error: Truffle is currently using solc 0.8.7, but one or more of your contracts specify "pragma solidity ^0.5.0".
[1] Please update your truffle config or pragma statement(s).
[1] (See https://trufflesuite.com/docs/truffle/reference/configuration#compiler-configuration for information on
[1] configuring Truffle to use a specific solc compiler version.)

2 Answers 2

1

You could try using pragma solidity <= 0.8.0 in your current contract that you referred here as My Contract

3
  • I just tried it and it didn't had any effect. I added the error logs in the OP.
    – PedroD
    Commented Nov 4, 2021 at 21:42
  • also configure your truffle compiler version accordingly as well Commented Nov 5, 2021 at 6:47
  • 1
    Yes, but I wanted to avoid that, because I want to use the new safeMath features only available on 0.8.0+. It is sad that they have breaking changes between minor versioning. In the end, I just noticed that 0.8.0 already accepts string[] as function arguments so I don't need to use the old library I was trying to use anymore.
    – PedroD
    Commented Nov 5, 2021 at 11:20
1

If you use truffle compiler, you can try the following steps

  1. specify openzeppelin version in package.json,

    "dependencies": { "@openzeppelin/contracts": "^4.4.0" },

  2. run npm install to install specified version dependence.

  3. run truffle compile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.