# Running a Solidity pre-release

Description: How to build and test your project with a Solidity pre-release, like 0.9.0-pre.1

Note: This document was authored using MDX

  Source: https://github.com/NomicFoundation/hardhat-website/tree/main/src/content/docs/docs/cookbook/solidity-prereleases.mdx

  Components used in this page:
    - <Run cmd="..."/>: Runs a command in the terminal with npm/pnpm/yarn.
    - :::caution: A warning callout block. Supports custom title `:::caution[Title]` and icon `:::caution{icon="name"}` syntax.

import Run from "@hh/Run.astro";

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

Set the compiler version to the pre-release's full version:

```ts {6-8}
// hardhat.config.ts
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:

<Run command="hardhat build" />

Hardhat 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:

<Run command="hardhat test" />

## 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`.

:::caution

Caret pragmas don't match `0.9.0-pre.1`: `^0.8.20` stops before any `0.9.0` pre-release, and `^0.9.0` starts at the `0.9.0` release. To try your contracts with the pre-release, change your caret pragmas to a range, like `>=0.8.20` or `>=0.8.20 <0.10.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`.
