# hardhat-abi-exporter

> Export Ethereum smart contract ABIs on compilation

Latest version **2.11.0** (published 2025-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install hardhat-abi-exporter
pnpm add hardhat-abi-exporter
yarn add hardhat-abi-exporter
bun add hardhat-abi-exporter
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.11.0 |
| Published | 2025-04-08 |
| First published | 2020-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.14.0 |
| Dependencies | 2 |
| Unpacked size | 36.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nick Barry |
| Maintainers | itsnickbarry |
| Keywords | hardhat, buidler, abi, solidity, solc, smart-contracts, ethereum, blockchain, version-control, wow, dapps |

## Links

- npm: https://www.npmjs.com/package/hardhat-abi-exporter
- Repository: https://github.com/ItsNickBarry/hardhat-abi-exporter
- npm.io page: https://npm.io/package/hardhat-abi-exporter

## Dependencies (2)

- [delete-empty](https://npm.io/package/delete-empty.md) ^3.0.0
- [@ethersproject/abi](https://npm.io/package/@ethersproject/abi.md) ^5.7.0

## 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.11.0 (latest) — 2025-04-08
- 2.10.1 — 2022-10-14
- 2.10.0 — 2022-07-03
- 2.9.0 — 2022-04-28
- 2.8.0 — 2022-01-17
- 2.7.2 — 2022-01-06
- 2.7.1 — 2022-01-06
- 2.7.0 — 2022-01-06
- 2.6.1 — 2022-01-01
- 2.6.0 — 2021-12-31
- 2.5.0 — 2021-12-30
- 2.4.1 — 2021-12-24
- 2.4.0 — 2021-12-19
- 2.3.1 — 2021-10-31
- 2.3.0 — 2021-08-31
- … 12 more at https://npm.io/package/hardhat-abi-exporter/versions

## README

# Hardhat ABI Exporter

Export Ethereum smart contract ABIs on compilation via Hardhat.

> Versions of this plugin prior to `2.0.0` were released as `buidler-abi-exporter`.

## Installation

```bash
npm install --save-dev hardhat-abi-exporter
# or
yarn add --dev hardhat-abi-exporter
```

## Usage

Load plugin in Hardhat config:

```javascript
require('hardhat-abi-exporter');
```

Add configuration under the `abiExporter` key:

| option         | description                                                                                                                                                  | default      |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------ |
| `path`         | path to ABI export directory (relative to Hardhat root)                                                                                                      | `'./abi'`    |
| `runOnCompile` | whether to automatically export ABIs during compilation                                                                                                      | `false`      |
| `clear`        | whether to delete old ABI files in `path` on compilation and on clean                                                                                        | `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                                                                                                       | `[]`         |
| `spacing`      | number of spaces per indentation level of formatted output                                                                                                   | `2`          |
| `pretty`       | whether to use interface-style formatting of output for better readability                                                                                   | `false`      |
| `format`       | format type ("json", "minimal", "fullName"). Alternative to `pretty`                                                                                         | `json`       |
| `filter`       | `Function` with signature `(abiElement: any, index: number, abi: any, fullyQualifiedName: string) => boolean` used to filter elements from each exported ABI | `() => true` |
| `rename`       | `Function` with signature `(sourceName: string, contractName: string) => string` used to rename an exported ABI (incompatible with `flat` option)            | `undefined`  |

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

```javascript
abiExporter: {
  path: './data/abi',
  runOnCompile: true,
  clear: true,
  flat: true,
  only: [':ERC20$'],
  spacing: 2,
  pretty: true,
  format: "minimal",
}

// or

abiExporter: [
  {
    path: './abi/pretty',
    pretty: true,
  },
  {
    path: './abi/ugly',
    pretty: false,
  },
]

// or

abiExporter: [
  {
    path: './abi/json',
    format: "json",
  },
  {
    path: './abi/minimal',
    format: "minimal",
  },
  {
    path: './abi/fullName',
    format: "fullName",
  },
]
```

The included Hardhat tasks may be run manually:

```bash
npx hardhat export-abi
npx hardhat clear-abi
# or
yarn run hardhat export-abi
yarn run hardhat clear-abi
```

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

```bash
npx hardhat export-abi --no-compile
# or
yarn run hardhat export-abi --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.

ABIs files are saved in the format `[CONTRACT_NAME].json`.

## Development

Install dependencies via Yarn:

```bash
yarn install
```

Setup Husky to format code on commit:

```bash
yarn prepare
```

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