# @solidstate/hardhat-bytecode-exporter

> Export Ethereum smart contract bytecode on compilation

Latest version **2.0.3** (published 2026-06-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @solidstate/hardhat-bytecode-exporter
pnpm add @solidstate/hardhat-bytecode-exporter
yarn add @solidstate/hardhat-bytecode-exporter
bun add @solidstate/hardhat-bytecode-exporter
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2026-06-07 |
| First published | 2022-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 35.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Nick Barry |
| Maintainers | itsnickbarry |
| Keywords | hardhat, buidler, bytecode, solidity, solc, smart-contracts, ethereum, blockchain, version-control, wow, dapps |

## Links

- npm: https://www.npmjs.com/package/@solidstate/hardhat-bytecode-exporter
- Repository: https://github.com/solidstate-network/hardhat-bytecode-exporter
- Homepage: https://github.com/solidstate-network/hardhat-bytecode-exporter#readme
- Issues: https://github.com/solidstate-network/hardhat-bytecode-exporter/issues
- npm.io page: https://npm.io/package/@solidstate/hardhat-bytecode-exporter

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^5.6.2
- [@solidstate/hardhat-solidstate-utils](https://npm.io/package/@solidstate/hardhat-solidstate-utils.md) ^1.0.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.3 (latest) — 2026-06-07
- 2.0.2 — 2026-05-29
- 2.0.1 — 2026-05-25
- 2.0.0 — 2025-08-13
- 1.1.1 — 2022-10-17
- 1.1.0 — 2022-10-17
- 1.0.0 — 2022-10-14

## README

# Hardhat Bytecode Exporter

Export Ethereum smart contract bytecode on compilation via Hardhat.

## Installation

```bash
npm install --save-dev @solidstate/hardhat-bytecode-exporter
# or
pnpm add -D @solidstate/hardhat-bytecode-exporter
```

## Usage

Load plugin in Hardhat config:

```javascript
import hardhatBytecodeExporter from '@solidstate/hardhat-bytecode-exporter';

const config: HardhatUserConfig = {
  plugins: [
    hardhatBytecodeExporter,
  ],
  bytecodeExporter: {
    ... // see table for configuration options
  },
};
```

Add configuration under the `bytecodeExporter` key:

| option         | description                                                                                                                                            | default        |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------- |
| `path`         | path to bytecode export directory (relative to Hardhat root)                                                                                           | `'./bytecode'` |
| `runOnCompile` | whether to automatically export bytecode during compilation                                                                                            | `false`        |
| `clear`        | whether to delete old bytecode files in `path` on compilation                                                                                          | `false`        |
| `flat`         | whether to flatten output directory (may cause name collisions)                                                                                        | `false`        |
| `only`         | `Array` of `String` matchers used to select included contracts, defaults to all contracts if `length` is 0                                             | `[]`           |
| `except`       | `Array` of `String` matchers used to exclude contracts                                                                                                 | `[]`           |
| `rename`       | `Function` with signature `(sourceName: string, contractName: string) => string` used to rename an exported bytecode (incompatible with `flat` option) | `undefined`    |

Note that the configuration may be formatted as either a single `Object`, or an `Array` of objects specifying multiple outputs.

```javascript
bytecodeExporter: {
  path: './data',
  runOnCompile: true,
  clear: true,
  flat: true,
  only: [':ERC20$'],
}

// or

bytecodeExporter: [
  {
    path: './only',
    runOnCompile: true,
    only: [':ERC20$'],
  },
  {
    path: './except',
    except: [':ERC20$'],
  },
]
```

The included Hardhat tasks may be run manually:

```bash
npx hardhat bytecode export
npx hardhat bytecode clean
# or
pnpm hardhat bytecode export
pnpm hardhat bytecode clean
```

By default, the hardhat `compile` task is run before exporting bytecode. This behavior can be disabled with the `--no-compile` flag:

```bash
npx hardhat bytecode export --no-compile
# or
pnpm hardhat bytecode export --no-compile
```

The `path` directory will be created if it does not exist.

The `clear` option is set to `false` by default because it represents a destructive action, but should be set to `true` in most cases.

Bytecode files are saved as a flat bin file in the format `[CONTRACT_NAME].bin`.

## Development

Install dependencies via pnpm:

```bash
pnpm install
```

Setup Husky to format code on commit:

```bash
pnpm prepare
```

---
_Source: https://npm.io/package/@solidstate/hardhat-bytecode-exporter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
