Reputation: 3222
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:
npm init -y
to initialise the directory as an npm projectnpm i -D hardhat
to install hardhat in the local directory (-D
to save as a dev dependency in the package.json)npx hardhat
and select the option to create the hardhat.config.js
filehardhat.config.js
file to target 0.8.1:/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.1",
};
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?
Upvotes: 1
Views: 2534
Reputation: 3222
I had Enable Local Node Compiler
set to true in my vscode extension config.
Disabling this (through the File -> Preferences GUI) and adding the following to .vscode/settings.json
sorted the problem:
{
"solidity.compileUsingRemoteVersion": "v0.8.1+commit.df193b15"
}
Upvotes: 2