Skip to content

Hardhat V3 can't compile #7578

@alex-hunter3

Description

@alex-hunter3

Version of Hardhat

3.0.7

What happened?

I was trying to compile my contracts after upgrading the package using bun before verifying some contracts I deployed tonight. However, now I'm getting an unexpected error:

computer@computer: ~/protocol$ bun compile
$ bunx --bun hardhat compile
An unexpected error occurred:

1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | exports.BroadcastedTxDifferentHash = exports.AccountIndexOutOfRange = exports.UnsupportedEventError = exports.NotImplementedError = exports.HardhatEthersError = void 0;
4 | const plugins_1 = require("hardhat/plugins");
5 | class HardhatEthersError extends plugins_1.NomicLabsHardhatPluginError {
                                     ^
TypeError: The superclass is not a constructor.
      at <anonymous> (/home/alex/Desktop/projects/cryndex-v2/protocol/node_modules/@nomicfoundation/hardhat-ethers/internal/errors.js:5:34)
      at <anonymous> (/home/alex/Desktop/projects/cryndex-v2/protocol/node_modules/@nomicfoundation/hardhat-ethers/internal/helpers.js:27:7)
      at <anonymous> (/home/alex/Desktop/projects/cryndex-v2/protocol/node_modules/@nomicfoundation/hardhat-ethers/internal/index.js:5:7)
      at <anonymous> (/home/alex/Desktop/projects/cryndex-v2/protocol/node_modules/@nomicfoundation/hardhat-chai-matchers/index.js:2:61)
      at <anonymous> (/home/alex/Desktop/projects/cryndex-v2/protocol/node_modules/@nomicfoundation/hardhat-toolbox/index.js:2:61)


If you think this is a bug in Hardhat, please report it here: https://hardhat.org/report-bug
error: script "compile" exited with code `1`

Minimal reproduction steps

Start up a new hardhat v3 project.

Setup the hardhat.config.ts:

// import "hardhat-contract-sizer"; // wasn't working either but not necessary right now
import "@nomicfoundation/hardhat-toolbox";
import hardhatVerify from "@nomicfoundation/hardhat-verify";
import { HardhatUserConfig } from "hardhat/config";
import dotenv from "dotenv";

dotenv.config();

const config: HardhatUserConfig = {
  plugins: [hardhatVerify],
  solidity: {
    compilers: [
      {
        version: "0.8.28",
        settings: {
          evmVersion: "cancun",
          viaIR: true,
          optimizer: {
            enabled: true,
            runs: 200,
          },
        },
      },
    ],
  },
  networks: {
    bsc: {
      chainId: 56,
      url: "https://bold-distinguished-layer.bsc.quiknode.pro/API_KEY",
      accounts: [process.env.WALLET_SECRET_KEY!],
    },
    hardhat: {
      allowUnlimitedContractSize: false,
      initialBaseFeePerGas: 0,
      forking: {
        url: "https://bsc-mainnet.infura.io/v3/<API_KEY>",
        blockNumber: 63786467,
      },
    },
  },
  contractSizer: {
    alphaSort: true,
    runOnCompile: true,
  },
  mocha: {
    timeout: 60000,
  },
  etherscan: {
    apiKey: {
      bsc: process.env.ETHERSCAN_API_KEY!,
    },
    customChains: [
      {
        network: "bsc",
        chainId: 56,
        urls: {
          apiURL: "https://api.etherscan.io/v2/api?chainid=56",
          browserURL: "https://bscscan.com",
        },
      },
    ],
  },
  sourcify: {
    enabled: false,
  },
};

export default config;

package.json:

{
  "type": "module",
  "scripts": {
    "compile": "bunx --bun hardhat compile",
    "htest": "bunx --bun hardhat test",
    "node": "bunx --bun hardhat node"
  },
  "dependencies": {
    "@chainlink/contracts": "^1.5.0",
    "@nomicfoundation/ethereumjs-util": "^9.0.4",
    "@nomiclabs/hardhat-ethers": "^2.2.3",
    "@nomiclabs/hardhat-etherscan": "^3.1.8",
    "@openzeppelin/contracts": "^5.4.0",
    "@pancakeswap/v3-core": "^1.0.2",
    "@pancakeswap/v3-periphery": "^1.0.2",
    "@types/bun": "^1.3.0",
    "hardhat": "^3.0.7",
    "hardhat-contract-sizer": "^2.10.1",
    "hardhat-verify": "^1.0.0"
  },
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^5.0.0",
    "dotenv": "^16.6.1"
  }
}

Run the command bun compile.

Search terms

solidity bnb bscscan

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions