Détail du package

@nomicfoundation/hardhat-viem

NomicFoundation67.1kMIT3.0.1

Hardhat plugin for viem

ethereum, smart-contracts, hardhat, hardhat-plugin

readme

hardhat-viem

This plugin integrates viem into Hardhat, adding a viem object to each network connection.

Installation

This plugin is part of the Viem Hardhat Toolbox. If you are using that toolbox, there's nothing else you need to do.

To install this plugin, run the following command:

npm install --save-dev @nomicfoundation/hardhat-viem

In your hardhat.config.ts file, import the plugin and add it to the plugins array:

import { defineConfig } from "hardhat/config";
import hardhatViem from "@nomicfoundation/hardhat-viem";

export default defineConfig({
  plugins: [hardhatViem],
});

Usage

This plugin adds a viem property to each network connection:

import { network } from "hardhat";

const { viem } = await hre.network.connect();

const publicClient = await viem.getPublicClient();
console.log(await publicClient.getBlockNumber());

const counter = await viem.deployContract("Counter");
await counter.write.inc();
console.log(await counter.read.x());

To learn more about using viem with Hardhat, read our guide.

changelog

@nomicfoundation/hardhat-viem

3.0.1

Patch Changes

  • 558ac5b: Update installation and config instructions

3.0.0

Major Changes

  • 29cc141: First release of Hardhat 3!

2.1.1

Patch Changes

  • bdba581: Fixed "Multiple networks with chain id found" error when multiple chains share the same chain id (#7065)

2.1.0

Minor Changes

  • 14b3042: Updated the minimal supported version of Node to v20 (#6982)

2.0.6

Patch Changes

  • 90bcfda: Remove unnecessary peerDependency

2.0.5

Patch Changes

  • 6010386: Moved types to HardhatViemHelpers and initialized ContractTypesMap as empty for better extensibility. Improved performance by disabling retries in dev nets (thanks @TateB!)

2.0.4

Patch Changes

  • efa905d: Fix for corrupted Hardhat peer dependency version from pnpm.

2.0.3

Patch Changes

  • a8a6038: Added ContractTypesMap to simplify contract type imports (thanks @beepidibop!)

2.0.2

Patch Changes

  • ccb0ace: Added support for library linking (thanks @Chlebamaticon!)

2.0.1

Patch Changes

  • a181462: Fix to add guard for updated TransactionReceipt type in viem

2.0.0

Major Changes

  • e4b1c07b7: Upgraded hardhat-viem to support viem@2

1.0.4

Patch Changes

  • 29516eb: Fixed broken link in network error message (thanks @sunsetlover36!).

1.0.3

Patch Changes

  • ffb301f14: Improved loading performance

1.0.2

Patch Changes

  • b521c2a05: Add configurable public client to getContractAt, deployContract and sendDeploymentTransaction

1.0.1

Patch Changes

  • 4943519d0: Fixed an issue with development networks using custom chain ids