I'm creating a new Ethereum project, using VScode (with Solidity extension) and hardhat. I want to use Solidity 0.8.1. I've done the following:
- Created a new directory for the project
- Run
npm init -yto initialise the directory as an npm project - Run
npm i -D hardhatto install hardhat in the local directory (-Dto save as a dev dependency in the package.json) - Run
npx hardhatand select the option to create thehardhat.config.jsfile - Edit the
hardhat.config.jsfile to target 0.8.1:
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.1",
};
- Created a contracts folder and created the following file
Token.sol:
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.1;
contract doStuff {
}
But the Solidity extension in VSCode complains with Source file requires different compiler version (current compiler is 0.7.3+commit.9bfce1f6.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version.
I think it's picking up the solc version installed in node_modules (0.7.3) - this must have been installed as part of hardhat.
How do I line up "everything" in the project so it uses 0.8.1?
Presumably you're not forced to use whatever version hardhat downloads of solc upon installation?
UPDATE:
I ran npx hardhat compile which appears to have downloaded the 0.8.1 compiler:
✔ Help us improve Hardhat with anonymous crash reports & basic usage data? (Y/n) · true
Downloading compiler 0.8.1
Compiling 1 file with 0.8.1
Compilation finished successfully
But the VSCode Solidity extension is still looking at the solc version in node_modules. How do I point the vscode extension at the latest version?