0

please check it out i already add comma after the curly here is the both file side by side with error returnedHere is the new error i get when using pragma solidity >=0.7.0 <0.9.0; Here is the   * contracts/hello-world.sol (^0.8.4) error i get when trying to compile with npx hardhat run scripts/interact.js --network ropsten  Hi Please am unable to figure out why i get this error while trying to compile my interact.js script using npx hardhat run scripts/interact.js --network ropsten on vs code : 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.

  • contracts/hello-world.sol ("0.8.4")

To learn more, run the command again with --verbose

here's my solidity code :

// SPDX-License-Identifier: MIT


pragma solidity "0.8.4";
contract HelloWorld {
    event updatedmessages(string oldStr, string newStr);

    string public message;

    constructor (string memory initmessage) {
    message = initmessage;
    }

    function update(string memory newMessage) public {
       string memory oldMsg = message;
       message = newMessage;
       emit updatedmessages(oldMsg,newMessage);
    }
}

here's the hardhat.config.js

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
 require('dotenv').config();
 require("@nomiclabs/hardhat-ethers");
 require("@nomiclabs/hardhat-etherscan");
 const { API_URL, PRIVATE_KEY } = process.env;
 const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY;
 module.exports = {
   solidity: "0.8.4",
   defaultNetwork: "ropsten",
   networks: {
       hardhat: {},
       ropsten: {
          url: API_URL,
          accounts: [`0x${PRIVATE_KEY}`]
       }
   },
   etherscan: {
     // Your API key for Etherscan
     // Obtain one at https://etherscan.io/
     apiKey:ETHERSCAN_API_KEY
   }
 };

ANY IDEA on how to solve this error [![here's the Sol file ][1][1] Please Help Thanks in Advance

2 Answers 2

0

try this:

at hartdhat.config.js

module.exports = {
  solidity: "0.7.1",
};

0.7.1--> 0.8.4 (solidity version you use in the smart contract)

if not work, comment below, or git upload code and give link.

13
  • Thanks i tried it already but still returns error: 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. * contracts/hello-world.sol (^0.8.4) To learn more, run the command again with --verbose Read about compiler configuration at hardhat.org/config Any idea on how to solve this Thanks
    – BHUNTX.eth
    Jun 12 at 10:58
  • try these: try 1. "0.8.4"; --> 0.8.0 (remove brackets). try 2: at solidity code: pragma solidity >=0.8.0 <0.9.0;. try 3: reduce solidity version on both .sol & hardhat.config.js e.g. 0.7.0 . tell if any of these 3 methods don't work.
    – aakash4dev
    Jun 12 at 11:03
  • i go this new error after using this pragma solidity >=0.7.0 <0.9.0;
    – BHUNTX.eth
    Jun 12 at 11:15
  • Downloading compiler 0.7.0 Compiled 1 Solidity file successfully /Users/user/Desktop/hello-world/contracts/hello-world.sol:4 pragma solidity >=0.7.0 <0.9.0; ^^^^^^^^ SyntaxError: Unexpected identifier at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1033:15) at Module._compile (node:internal/modules/cjs/loader:1069:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32)
    – BHUNTX.eth
    Jun 12 at 11:16
  • Any idea what the problem is here Please
    – BHUNTX.eth
    Jun 12 at 11:16
0

it needs to match up with what's in module.exports in your hardhat.config.js

but the quotes in the contract are causing the problem

try this

pragma solidity ^0.8.4;
18
  • Thanks I already changed that but it still give error
    – BHUNTX.eth
    Jun 12 at 10:56
  • 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. * contracts/hello-world.sol (^0.8.4) To learn more, run the command again with --verbose Read about compiler configuration at hardhat.org/config Any idea please Help
    – BHUNTX.eth
    Jun 12 at 10:57
  • Please Any idea on how to solve this i have attached a new image of the error i got
    – BHUNTX.eth
    Jun 12 at 11:03
  • this image is showing the contract's pragma statement has the version inside quote marks instead of like this ^0.8.4
    – sola24
    Jun 12 at 11:08
  • i already changed it to this pragma solidity >=0.7.0 <0.9.0; but it returned a new error
    – BHUNTX.eth
    Jun 12 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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