# Hardhat

deployoor reads Hardhat `artifacts/` — **both Hardhat 2 and Hardhat 3** — and generates typed deployers from them.

## Compile and generate

```bash
npx hardhat compile && npx deployoor generate
```

| Input              | Location           |
| ------------------ | ------------------ |
| Compiled artifacts | `artifacts/`       |
| Config file        | `hardhat.config.*` |

## Auto-generate on compile

Add `@deployoor/hardhat` to skip the separate `generate` step — it regenerates `./deployers/` after every `hardhat compile`. It ships an entry for each Hardhat major.

```bash
pnpm add -D @deployoor/hardhat deployoor viem
```

**Hardhat 2** — register by side effect:

```js
// hardhat.config.js
require("@deployoor/hardhat");

module.exports = { solidity: "0.8.24" };
```

**Hardhat 3** — import the `/v3` plugin object and add it to `plugins`:

```ts
// hardhat.config.ts
import { defineConfig } from "hardhat/config";
import deployoor from "@deployoor/hardhat/v3";

export default defineConfig({ plugins: [deployoor], solidity: "0.8.28" });
```

Either way:

```bash
npx hardhat compile
# deployoor: generated 3 deployer file(s)
```

Prefer no plugin? `deployoor generate` reads Hardhat 2 and Hardhat 3 `artifacts/` directly (it resolves each artifact's inline `buildInfoId` to `artifacts/build-info/<id>.json` on Hardhat 3), so `npx hardhat compile && npx deployoor generate` works too.

## Example

Runnable examples: [`examples/hardhat`](https://github.com/raycashxyz/deployoor/tree/main/examples/hardhat) (Hardhat 2) and [`examples/hardhat-v3`](https://github.com/raycashxyz/deployoor/tree/main/examples/hardhat-v3) (Hardhat 3) — both use the plugin: compile → auto-generate → deploy → committed record.
