Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/warm-solx-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nomicfoundation/hardhat-solx": major
"@nomicfoundation/hardhat-errors": patch
---

Add `@nomicfoundation/hardhat-solx` plugin for solx compiler support in test builds ([#8034](https://github.com/NomicFoundation/hardhat/pull/8034))
5 changes: 5 additions & 0 deletions .peer-bumps.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"packages/config"
],
"bumps": [
{
"package": "@nomicfoundation/hardhat-solx",
"peer": "hardhat",
"reason": "It depends on the new SolidityHooks#downloadCompilers and SolidityHooks#getCompiler hooks"
},
{
"package": "@nomicfoundation/hardhat-ignition-viem",
"peer": "@nomicfoundation/hardhat-ignition",
Expand Down
43 changes: 43 additions & 0 deletions packages/hardhat-errors/src/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,19 @@ export const ERROR_CATEGORIES: {
},
},
},
HARDHAT_SOLX: {
min: 110000,
max: 119999,
pluginId: "hardhat-solx",
websiteTitle: "Hardhat Solx",
CATEGORIES: {
GENERAL: {
min: 110000,
max: 110099,
websiteSubTitle: "General errors",
},
},
},
};

export const ERRORS = {
Expand Down Expand Up @@ -3063,4 +3076,34 @@ Check the error message for more details and verify your foundry.toml configurat
},
},
},
HARDHAT_SOLX: {
GENERAL: {
UNSUPPORTED_PLATFORM: {
number: 110000,
messageTemplate: `solx is not available for the current platform ({platform}/{arch}).

solx supports: linux/x64, linux/arm64, darwin (macOS), windows/x64.`,
Comment thread
alcuadrado marked this conversation as resolved.
websiteTitle: "Unsupported platform",
websiteDescription: `The solx compiler is not available for your current operating system and architecture combination.

solx supports: linux/x64, linux/arm64, darwin (macOS), windows/x64.`,
},
DOWNLOAD_FAILED: {
number: 110001,
messageTemplate: `Failed to download solx {version} after {attempts} attempts: {reason}`,
websiteTitle: "solx download failed",
websiteDescription: `The solx compiler binary could not be downloaded from the solx releases mirror used by Hardhat.

Check your internet connection, ensure that the solx releases mirror (https://solx-releases-mirror.hardhat.org) is reachable from your environment, and verify that the requested solx version exists.`,
},
BINARY_NOT_FOUND: {
number: 110002,
messageTemplate: `solx binary not found at {path}`,
websiteTitle: "solx binary not found",
websiteDescription: `The configured custom path for the solx binary does not exist.

Verify that the path in your Hardhat config points to a valid solx binary.`,
},
},
},
} as const;
14 changes: 14 additions & 0 deletions packages/hardhat-solx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Node modules
/node_modules

# Compilation output
/dist

# pnpm deploy output
/bundle

# test coverage output
coverage

# all the tmp folders in the fixture projects
/test/fixture-projects/tmp/
6 changes: 6 additions & 0 deletions packages/hardhat-solx/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/dist
/coverage
CHANGELOG.md
/test/fixture-projects/**/artifacts
/test/fixture-projects/**/cache
9 changes: 9 additions & 0 deletions packages/hardhat-solx/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2026 Nomic Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
104 changes: 104 additions & 0 deletions packages/hardhat-solx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Hardhat Solx plugin

This plugin enables the [solx](https://github.com/NomicFoundation/solx) Solidity compiler in Hardhat 3.

The `solx` compiler is currently experimental and is not ready for production use-cases. We recommend using the compiler for test builds and test execution locally, and continuing to use `solc` for production use-cases (including during deployment for example with `hardhat-ignition` and in your CI). Care should be taken before enabling compilation with `solx` in other build profiles, see configuration flags further below.

## Installation

```bash
npm install --save-dev @nomicfoundation/hardhat-solx
```

Then add the plugin to your `hardhat.config.ts` and create a `solx` build profile. You must use the build profiles config format, which requires both a `default` and a `solx` profile:

```typescript
import { defineConfig } from "hardhat/config";
import hardhatSolx from "@nomicfoundation/hardhat-solx";
Comment on lines +9 to +17
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Installation section suggests installing @nomicfoundation/hardhat-solx from npm, but the new package is currently marked private and is excluded from release tooling (scripts/lib/packages.ts). Either make the package publishable, or update these instructions to match the intended distribution method.

Suggested change
```bash
npm install --save-dev @nomicfoundation/hardhat-solx
```
Then add the plugin to your `hardhat.config.ts` and create a `solx` build profile. You must use the build profiles config format, which requires both a `default` and a `solx` profile:
```typescript
import { defineConfig } from "hardhat/config";
import hardhatSolx from "@nomicfoundation/hardhat-solx";
This plugin is currently experimental and is not published to npm. It is intended to be used from within the Hardhat monorepo or from source.
Once the plugin is available in your project, add it to your `hardhat.config.ts` and create a `solx` build profile. You must use the build profiles config format, which requires both a `default` and a `solx` profile:
```typescript
import { defineConfig } from "hardhat/config";
import hardhatSolx from "@nomicfoundation/hardhat-solx";
import { defineConfig } from "hardhat/config";
import hardhatSolx from "@nomicfoundation/hardhat-solx";

Copilot uses AI. Check for mistakes.

export default defineConfig({
plugins: [hardhatSolx],
solidity: {
profiles: {
default: {
version: "0.8.29",
},
solx: {
type: "solx",
version: "0.8.34",
},
},
},
});
```

The `default` profile uses solc as usual. The `solx` profile uses the solx compiler, identified by `type: "solx"`. Your `.sol` files should have compatible pragmas, for example `pragma solidity ^0.8.29;`. Strict pragmas for unsupported Solidity versions, for example `pragma solidity 0.8.28;`, will currently not compile with this hardhat-solx plugin. See more details below for the currently supported Solidity versions and EVM versions.

## Usage

Run tests or compile using the solx-powered build profile:

```bash
hardhat test --build-profile solx
hardhat build --build-profile solx
```

The default profile continues to use solc as usual:

```bash
hardhat build # uses solc (default profile)
```

## Configuration

### Multi-version example

You can configure the `solx` profile with multiple compilers. Compilers without `type: "solx"` will use solc:

```typescript
export default defineConfig({
plugins: [hardhatSolx],
solidity: {
profiles: {
default: {
compilers: [{ version: "0.8.34" }, { version: "0.8.20" }],
},
solx: {
compilers: [
{ type: "solx", version: "0.8.34" },
{ version: "0.8.20" }, // uses solc, solx doesn't support this version
],
},
},
},
});
```

### Options

- `dangerouslyAllowSolxInProduction` (`boolean`, default: `false`), allows compiler type `"solx"` in build profiles other than `solx`. By default, using `type: "solx"` in any other profile (e.g. `default`, `production`) will produce a validation error.

```typescript
export default defineConfig({
plugins: [hardhatSolx],
solidity: {
profiles: {
default: {
type: "solx", // returns a validation error.
version: "0.8.34",
},
},
},
solx: {
dangerouslyAllowSolxInProduction: false, // default false, switching this to true will allow `type: "solx"` on the default profile.
},
});
```

### Supported Solidity versions

solx maps each Solidity version to a specific solx binary version internally. Currently supported: `0.8.33` (solx 0.1.3), `0.8.34` (solx 0.1.4).

### EVM version support

solx supports EVM versions `cancun`, `prague`, and `osaka`. Using an older EVM target (e.g., `paris`, `shanghai`) with compiler type `"solx"` will result in a validation error.
3 changes: 3 additions & 0 deletions packages/hardhat-solx/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createConfig } from "../config/eslint.config.js";

export default createConfig(import.meta.filename);
70 changes: 70 additions & 0 deletions packages/hardhat-solx/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"name": "@nomicfoundation/hardhat-solx",
"private": true,
"version": "2.0.0",
"description": "Hardhat plugin for using solx compiler in test builds",
"homepage": "https://github.com/NomicFoundation/hardhat/tree/main/packages/hardhat-solx",
Comment on lines +1 to +6
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package is marked "private": true, which prevents publishing to npm, but the PR introduces a changeset and README instructions for npm install --save-dev @nomicfoundation/hardhat-solx. Please align these: either remove private (and ensure release tooling includes the package), or adjust docs/changesets to reflect that the plugin is not meant to be installed from npm.

Copilot uses AI. Check for mistakes.
"repository": {
"type": "git",
"url": "https://github.com/NomicFoundation/hardhat",
"directory": "packages/hardhat-solx"
},
"author": "Nomic Foundation",
"license": "MIT",
"type": "module",
"types": "dist/src/index.d.ts",
"exports": {
".": "./dist/src/index.js"
},
"keywords": [
"ethereum",
"smart-contracts",
"hardhat",
"solx",
"compiler"
],
"scripts": {
"lint": "pnpm prettier --check && pnpm eslint",
"lint:fix": "pnpm prettier --write && pnpm eslint --fix",
"eslint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
"prettier": "prettier \"**/*.{ts,js,md,json}\"",
"test": "node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
"test:only": "node --import tsx/esm --test --test-only --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
"test:coverage": "c8 --reporter html --reporter text --all --exclude test --exclude \"src/**/{types,type-extensions}.ts\" --src src node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
"pretest": "pnpm build",
"pretest:only": "pnpm build",
"build": "tsc --build .",
"prepublishOnly": "pnpm build",
"clean": "rimraf dist"
},
"files": [
"dist/src/",
"src/",
"CHANGELOG.md",
"LICENSE",
"README.md"
],
"devDependencies": {
"@nomicfoundation/hardhat-node-test-reporter": "workspace:^3.0.0",
"@nomicfoundation/hardhat-test-utils": "workspace:^",
"@types/debug": "^4.1.7",
"@types/node": "^22.0.0",
"c8": "^9.1.0",
"eslint": "9.25.1",
"prettier": "3.2.5",
"rimraf": "^5.0.5",
"tsx": "^4.19.3",
"typescript": "~5.8.0",
"hardhat": "workspace:^3.1.6"
},
"dependencies": {
"@nomicfoundation/hardhat-errors": "workspace:^3.0.3",
"@nomicfoundation/hardhat-utils": "workspace:^3.0.5",
"@nomicfoundation/hardhat-zod-utils": "workspace:^3.0.0",
"debug": "^4.3.2",
"zod": "^3.23.8"
},
"peerDependencies": {
"hardhat": "workspace:^3.1.6"
}
}
14 changes: 14 additions & 0 deletions packages/hardhat-solx/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { HardhatPlugin } from "hardhat/types/plugins";

import "./type-extensions.js";

const hardhatSolxPlugin: HardhatPlugin = {
id: "hardhat-solx",
npmPackage: "@nomicfoundation/hardhat-solx",
hookHandlers: {
config: () => import("./internal/hook-handlers/config.js"),
solidity: () => import("./internal/hook-handlers/solidity.js"),
},
};

export default hardhatSolxPlugin;
30 changes: 30 additions & 0 deletions packages/hardhat-solx/src/internal/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { SolidityCompilerType } from "hardhat/types/config";

/**
* The compiler type identifier registered by this plugin.
* Typed as SolidityCompilerType for type-safe comparisons.
*/
export const SOLX_COMPILER_TYPE: SolidityCompilerType = "solx";

export const SOLX_RELEASES_BASE_URL =
"https://solx-releases-mirror.hardhat.org";

export const SUPPORTED_SOLX_EVM_VERSIONS: readonly string[] = [
"cancun",
"prague",
"osaka",
] as const;

export const DEFAULT_SOLX_SETTINGS: Record<string, unknown> = {
viaIR: false,
LLVMOptimization: "1",
};

/**
* Maps Solidity compiler versions to the solx version that embeds them.
* Only stable solx releases are included.
*/
export const SOLIDITY_TO_SOLX_VERSION_MAP: Record<string, string> = {
"0.8.33": "0.1.3",
"0.8.34": "0.1.4",
};
Loading
Loading