diff --git a/packages/hardhat-core/src/builtin-tasks/compile.ts b/packages/hardhat-core/src/builtin-tasks/compile.ts index 7d5f5e4df5..1d2b592ecd 100644 --- a/packages/hardhat-core/src/builtin-tasks/compile.ts +++ b/packages/hardhat-core/src/builtin-tasks/compile.ts @@ -99,6 +99,8 @@ function isConsoleLogError(error: any): boolean { const log = debug("hardhat:core:tasks:compile"); +const COMPILE_TASK_FIRST_SOLC_VERSION_SUPPORTED = "0.4.11"; + /** * Returns a list of absolute paths to all the solidity files in the project. * This list doesn't include dependencies, for example solidity files inside @@ -643,6 +645,18 @@ subtask(TASK_COMPILE_SOLIDITY_COMPILE_SOLC) }, { run } ): Promise<{ output: CompilerOutput; solcBuild: SolcBuild }> => { + // versions older than 0.4.11 don't work with hardhat + // see issue https://github.com/nomiclabs/hardhat/issues/2004 + if (semver.lt(solcVersion, COMPILE_TASK_FIRST_SOLC_VERSION_SUPPORTED)) { + throw new HardhatError( + ERRORS.BUILTIN_TASKS.COMPILE_TASK_UNSUPPORTED_SOLC_VERSION, + { + version: solcVersion, + firstSupportedVersion: COMPILE_TASK_FIRST_SOLC_VERSION_SUPPORTED, + } + ); + } + const solcBuild: SolcBuild = await run( TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD, { diff --git a/packages/hardhat-core/src/internal/core/errors-list.ts b/packages/hardhat-core/src/internal/core/errors-list.ts index b4d3932668..93ce6b8c62 100644 --- a/packages/hardhat-core/src/internal/core/errors-list.ts +++ b/packages/hardhat-core/src/internal/core/errors-list.ts @@ -861,6 +861,16 @@ To start the JSON-RPC server, retry the command without the --network parameter. if the URL of the JSON-RPC wasn't set.`, shouldBeReported: false, }, + COMPILE_TASK_UNSUPPORTED_SOLC_VERSION: { + number: 608, + message: `Version %version% is not supported by Hardhat. + +The first supported version is %firstSupportedVersion%`, + title: "Unsupported solc version", + description: `This version of solidity is not supported by Hardhtat. +Please use a newer, supported version.`, + shouldBeReported: true, + }, }, ARTIFACTS: { NOT_FOUND: {