Running a Solidity pre-release
The Solidity team publishes pre-releases of upcoming compiler versions, like 0.9.0-pre.1, so that you can try your contracts against them before the release. This guide shows you how to build and test your project with Solidity 0.9.0-pre.1.
Configuring the pre-release
Section titled “Configuring the pre-release”Set the compiler version to the pre-release’s full version:
import { defineConfig } from "hardhat/config";
export default defineConfig({ //... solidity: { version: "0.9.0-pre.1", },});Hardhat downloads a pre-release only when you configure its full version, including the -pre.1 suffix. A plain 0.9.0 always means the release, so you never get a pre-release by accident.
With that in place, build your project as usual:
npx hardhat buildpnpm hardhat buildyarn hardhat buildHardhat prints the compiler it used, along with a warning from solc itself:
Warning: This is a pre-release compiler version, please do not use it in production.
Compiled 2 Solidity files with solc 0.9.0-pre.1 (evm target: osaka)Your tests, whether Solidity or TypeScript tests, will run under the pre-release version of the compiler as well:
npx hardhat testpnpm hardhat testyarn hardhat testMaking your pragmas match the pre-release
Section titled “Making your pragmas match the pre-release”Hardhat matches a pre-release against version pragmas the same way solc does. If solc would refuse to compile a file with the pre-release, Hardhat won’t select that pre-release.
The rule solc follows is that a pre-release comes just before its release: 0.9.0-pre.1 is higher than every 0.8 version, but lower than 0.9.0.
Write your pragmas with full versions, like >=0.8.20. Hardhat doesn’t match a pre-release against pragmas with a partial version, like 0.9, 0.9.x, or >=0.8.