Solidity, compiler version error incompatible - solidity

I know is a typical error but I don't know how to solve it. I have tried to add the compile version in the hardhat config file but it doesn't work.
Error HH606: The project cannot be compiled, see reasons below.
These files import other files that use a different and incompatible version of Solidity:
contracts/MarketOrder.sol (^0.8.8) imports #openzeppelin/contracts/token/ERC20/ERC20.sol (^0.7.0)
To learn more, run the command again with --verbose
Read about compiler configuration at https://hardhat.org/config
Without adding the 0.7.0:
Error HH606: The project cannot be compiled, see reasons below.
The Solidity version pragma statement in these files doesn't match any of the configured compilers in your config. Change the pragma or configure additional compiler versions in your hardhat config.
* #openzeppelin/contracts/token/ERC20/ERC20.sol (^0.7.0)
* #openzeppelin/contracts/math/SafeMath.sol (^0.7.0)
* #openzeppelin/contracts/token/ERC20/IERC20.sol (^0.7.0)
These files import other files that use a different and incompatible version of Solidity:
* contracts/MarketOrder.sol (^0.8.8) imports #openzeppelin/contracts/token/ERC20/ERC20.sol (^0.7.0)
These files and its dependencies cannot be compiled with your config. This can happen because they have incompatible Solidity pragmas, or don't match any of your configured Solidity compilers.
* #uniswap/v3-periphery/contracts/libraries/TransferHelper.sol
To learn more, run the command again with --verbose
Read about compiler configuration at https://hardhat.org/config

Inside the hardhat.config file you can add multiple compiler versions, find the snippet similar to and add the compiler version which is required.
solidity: {
compilers: [
{
version: "0.8.8",
},
{
version: "0.7.0",
},
],
}

Related

Solidity, hardhat failing to compile multiple Solidity versions

I'm having this issue, even adding the versions in the hardhat.config file.
module.exports = {
solidity: {
compilers: [{version: "0.6.6"}, {version: "0.4.19"}, {version: "0.6.12"}, {version: "0.8.8"}, {version: "0.7.0"}]
},
Here is still the error, What can I do?? The contract works perfectly in remix.
Error HH606: The project cannot be compiled, see reasons below.
These files import other files that use a different and incompatible version of Solidity:
* contracts/MarketOrder.sol (^0.8.8) imports #openzeppelin/contracts/token/ERC20/ERC20.sol (^0.7.0)
To learn more, run the command again with --verbose
Read about compiler configuration at https://hardhat.org/config
Your MarketOrder.sol contract has been configured for Solidity 0.8, whereas the imported OpenZeppelin contract is Solidity 0.7
Update your #openzeppelin/contracts package to the latest version or at least one that supports ^0.8.0

Imports for "#chainlink" and "#openzeppelinn" are broken

Whenever I try to do an import like the two demonstrated below, they are not recognized. I am using VSCode. Yes I have tried installing and uninstalling many times. If anybody knows why that would be EPIC. Thanks.
import "#chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "#openzeppelin/contracts/token/ERC721/ERC721Full.sol";
VSC Solidity extension can't read Brownie's remappings. I'm assuming that you're getting this error:
Source
"#chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"
not found: File import callback not supported
Source "#openzeppelin/contracts/token/ERC721/ERC721Full.sol" not
found: File import callback not supported
Make sure you set dependencies and remappings correctly in brownie-config.yaml:
dependencies:
- smartcontractkit/chainlink-brownie-contracts#0.2.1
- OpenZeppelin/openzeppelin-contracts#3.4.0
compiler:
solc:
remappings:
- '#chainlink=smartcontractkit/chainlink-brownie-contracts#0.2.1'
- '#openzeppelin=OpenZeppelin/openzeppelin-contracts#3.4.0'
Compile your contracts:
brownie compile
If compiled successfully, Brownie should have downloaded packages, you can confirm it by running
brownie pm list
Set remappings for VSCode Solidity extension (for example in ./vscode/settings.json).
"solidity.remappings": [
"#chainlink/=<PATH_TO_BROWNIE_STUFF>/.brownie/packages/smartcontractkit/chainlink-brownie-contracts#0.2.1",
"#openzeppelin/=<PATH_TO_BROWNIE_STUFF>/.brownie/packages/OpenZeppelin/openzeppelin-contracts#3.4.0",
]
Make sure that you got the versions (#x.x.x) right across all the config files.
If you're on Linux, <PATH_TO_BROWNIE_STUFF> would probably be your home directory (/home/jjreedv)
As of Feb 2022, the remappings code settings for VS Code have been updated to be OS specific.
Here's an example:
{
"solidity.remappingsUnix": [
"#chainlink-brownie-contracts/=/home/<USERNAME>/.brownie/packages/smartcontractkit/chainlink-brownie-contracts#0.4.1",
"#openzeppelin/=/home/<USERNAME>/.brownie/packages/OpenZeppelin/openzeppelin-contracts#4.6.0",
],
"solidity.remappingsWindows": [
"#openzeppelin/=C:/Users/<USERNAME>/.brownie/packages/OpenZeppelin/openzeppelin-contracts#4.6.0",
"#chainlink-brownie-contracts/=C:/Users/<USERNAME>/.brownie/packages/smartcontractkit/chainlink-brownie-contracts#0.4.1",
],
Official README of project:
https://github.com/juanfranblanco/vscode-solidity#platform-specific-remappings

How to develop and compile with hardhat using imports with different pragma/compiler versions?

hardhat does not support https imports. After installing openzeppelin and chainlink with npm and using #openzeppelin/#chainlink, we get pragma/compiler version issues, even with different compiler versions in hardhat.config.js, and even with overwrites. How do you develop and compile with hardhat and these imports?
In your hardhat.config.js you can add multiple compilers.
module.exports = {
solidity: {
compilers: [
{
version: "0.6.6"
},
{
version: "0.4.24"
}
]
}
}
I faced this problem, i wanted to interface with Venus protocol....so i basically put all the interfaces and the contract inside one file with the contract to avoid running multiple instances of the solidity compiler.

How to compile older zeppelin-solidity contract implementations

I installed zeppelin-solidity package using npm, to use the erc-721 contract.
But the problem is that when I use truffle compile, it gives the following error:
/Users/me/dev/myfolder/erc721/node_modules/zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.5.16+commit.9c3226ce.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.4.24;
^----------------------^
Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify "pragma solidity ^0.4.24".
Please update your truffle config or pragma statement(s).
(See https://truffleframework.com/docs/truffle/reference/configuration#compiler-configuration for information on
configuring Truffle to use a specific solc compiler version.)
Compilation failed. See above.
Some answers I saw are suggesting to bump up the pragma solidity to 0.5, but how can i change the version in an included file?
Also if this contract is old should i be using it, or are there better implementations of erc721 available?
UPDATE:
I have tried changing the solc compiler as below, but still the error persists:
compilers: {
solc: {
version: "^0.4.24",
//parser: "solcjs",
optimizer: {
enabled: true,
runs: 200
}
}
}
Write a file called truffle.js such as:
module.exports = {
// Configure your compilers
compilers: {
solc: {
version: ">=0.4.24", // Fetch exact version from solc-bin (default: truffle's version)
}
},
};
and place it under the project root directory. That's it.
Read more about Truffle configurations: https://www.trufflesuite.com/docs/truffle/reference/configuration

PixiJS for Haxe won't import - Type Not Found error in IntelliJ

I'm trying to run the most basic PixiJS for Haxe sample program, but IntelliJ gives a Type Not Found error.
The failing code:
package ;
import pixi.core.Application;
The error message:
Main.hx:3: characters 7-28 : Type not found : pixi.core.Application
I think the issue is PixiJS-specific, as when I follow the same install-and-import steps for other Haxe modules (eg flambe, flixel) they behave as expected. I've tried with both 4.7.1 and 4.5.5, and as both global and project-specific libraries (separately).
(I hybridized several screenshots to save space)
When running from the console, using:
> haxe -main Main -lib pixijs -js output.js
Everything seems to compile (running the compiled code results in a PIXI is not defined error which is a seperate issue).
UPDATE 1, how I'm adding the dependency:
After executing haxelib install pixijs, I follow these steps:
UDPATE 2, the config being run:
If you can't get it working in the dependencies section you could try adding the haxelibs pixijs externs src/ folder as an additional sources root in Project Structure -> Modules -> (module name) -> Sources. That's how it worked for me: