Skip to content

Commit

Permalink
Capitalize Viem and other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Oct 11, 2023
1 parent 197f72b commit 4c5839e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions docs/src/content/hardhat-runner/docs/advanced/using-viem.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Using viem
# Using Viem

## Overview

Most of this documentation assumes that you are using [ethers](https://docs.ethers.org/v6/) as your connection library, but you can also use Hardhat with [viem](https://viem.sh/docs/introduction.html), a more lightweight and type-safe alternative. This guide explains how to setup a project that uses [the viem-based Toolbox](/hardhat-runner/plugins/nomicfoundation-hardhat-toolbox-viem) instead of the main one.
Most of this documentation assumes that you are using [ethers](https://docs.ethers.org/v6/) as your connection library, but you can also use Hardhat with [Viem](https://viem.sh/docs/introduction.html), a more lightweight and type-safe alternative. This guide explains how to setup a project that uses [the Viem-based Toolbox](/hardhat-runner/plugins/nomicfoundation-hardhat-toolbox-viem) instead of the main one.

## Installation

To kickstart a Hardhat project with Typescript and `viem`, you can follow these steps:
To kickstart a Hardhat project with Typescript and Viem, you can follow these steps:

1. Initialize a new npm project in an empty directory:

Expand Down Expand Up @@ -68,9 +68,9 @@ To kickstart a Hardhat project with Typescript and `viem`, you can follow these

::::

3. Run `npx hardhat init` and select the _Create a TypeScript project (with viem)_ option.
3. Run `npx hardhat init` and select the _Create a TypeScript project (with Viem)_ option.

**Note:** you might want to pin viem-related dependencies because viem does not strictly follow semantic versioning for type changes. You can read more [here](#managing-types-and-version-stability).
**Note:** you might want to pin Viem-related dependencies because Viem does not strictly follow semantic versioning for type changes. You can read more [here](#managing-types-and-version-stability).

## Quick Start

Expand Down Expand Up @@ -211,7 +211,7 @@ To access contract methods, import the Hardhat Runtime Environment and use the `

#### Contract Type Generation

The proper types for each contract are generated during compilation. These types are used to overload the hardhat-viem types and improve type checking and suggestions. For example, if you copy and paste the following code at the end of the `main()` function of `scripts/contracts.ts`, TypeScript would highlight it as an error:
The proper types for each contract are generated during compilation. These types are used to overload the `hardhat-viem` types and improve type checking and suggestions. For example, if you copy and paste the following code at the end of the `main()` function of `scripts/contracts.ts`, TypeScript would highlight it as an error:

```tsx
// The amount is required as a parameter
Expand All @@ -227,7 +227,7 @@ const tokenPrice = await myToken.write.setSupply([5000000n]);
const myToken2 = await hre.viem.deployContract("MyToken", ["1000000"]);
```

If you want to learn more about working with contracts, you can visit the [hardhat-viem plugin site](/hardhat-runner/plugins/nomicfoundation-hardhat-viem#contracts) and [Viem's official site](https://viem.sh/docs/contract/getContract.html).
If you want to learn more about working with contracts, you can visit the [`hardhat-viem` plugin site](/hardhat-runner/plugins/nomicfoundation-hardhat-viem#contracts) and [Viem's official site](https://viem.sh/docs/contract/getContract.html).

### Testing

Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-core/src/internal/cli/project-creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { Dependencies, PackageManager } from "./types";
enum Action {
CREATE_JAVASCRIPT_PROJECT_ACTION = "Create a JavaScript project",
CREATE_TYPESCRIPT_PROJECT_ACTION = "Create a TypeScript project",
CREATE_TYPESCRIPT_VIEM_PROJECT_ACTION = "Create a TypeScript project (with viem)",
CREATE_TYPESCRIPT_VIEM_PROJECT_ACTION = "Create a TypeScript project (with Viem)",
CREATE_EMPTY_HARDHAT_CONFIG_ACTION = "Create an empty hardhat.config.js",
QUIT_ACTION = "Quit",
}
Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat-toolbox-viem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ The `@nomicfoundation/hardhat-toolbox-viem` plugin bundles all the commonly used

When you use this plugin, you'll be able to:

- Deploy and interact with your contracts using [viem](https://viem.sh/) and the [`hardhat-viem`](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-viem) plugin.
- Test your contracts with [Mocha](https://mochajs.org/), [Chai](https://chaijs.com/) and [Chai as Promised](https://github.com/domenic/chai-as-promised#chai-assertions-for-promises). Note: the plugin Hardhat Chai Matchers is currently not available for viem.
- Deploy and interact with your contracts using [Viem](https://viem.sh/) and the [`hardhat-viem`](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-viem) plugin.
- Test your contracts with [Mocha](https://mochajs.org/), [Chai](https://chaijs.com/) and [Chai as Promised](https://github.com/domenic/chai-as-promised#chai-assertions-for-promises). Note: the plugin Hardhat Chai Matchers is currently not available for Viem.
- Interact with Hardhat Network with our [Hardhat Network Helpers](https://hardhat.org/hardhat-network-helpers).
- Verify the source code of your contracts with the [hardhat-verify](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify) plugin.
- Get metrics on the gas used by your contracts with the [hardhat-gas-reporter](https://github.com/cgewecke/hardhat-gas-reporter) plugin.
- Measure your tests coverage with [solidity-coverage](https://github.com/sc-forks/solidity-coverage).

**Note:** you might want to pin viem-related dependencies because viem does not strictly follow semantic versioning for type changes. You can read more [here](https://hardhat.org/hardhat-runner/docs/advanced/using-viem#managing-types-and-version-stability).
**Note:** you might want to pin Viem-related dependencies because Viem does not strictly follow semantic versioning for type changes. You can read more [here](https://hardhat.org/hardhat-runner/docs/advanced/using-viem#managing-types-and-version-stability).

### Usage

To create a new project that uses the Toolbox, check our [Setting up a project guide](https://hardhat.org/hardhat-runner/docs/guides/project-setup) but select the _Create a TypeScript project (with viem)_ option instead.
To create a new project that uses the Toolbox, check our [Setting up a project guide](https://hardhat.org/hardhat-runner/docs/guides/project-setup) but select the _Create a TypeScript project (with Viem)_ option instead.

### Network Helpers

Expand Down
10 changes: 5 additions & 5 deletions packages/hardhat-viem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# hardhat-viem

[Hardhat](https://hardhat.org) plugin for integration with [viem](https://github.com/wagmi-dev/viem), an alternative Ethereum library.
[Hardhat](https://hardhat.org) plugin for integration with [Viem](https://github.com/wagmi-dev/viem), a lightweight, composable, and type-safe Ethereum library.

## What

This plugin integrates the Viem Ethereum library into your Hardhat development environment. Viem is designed as an alternative to ethers.js, offering developers a different way to interact with the Ethereum blockchain.
This plugin integrates the Viem Ethereum library into your Hardhat development environment. Viem is an alternative to [ethers.js](https://docs.ethers.io/) that offers developers a different way to interact with the Ethereum blockchain.

By installing and configuring `hardhat-viem`, you gain access to the capabilities of the Viem library directly within your Hardhat projects. This integration enables you to perform various Ethereum-related tasks using Viem's features and functionalities.

Expand All @@ -30,7 +30,7 @@ Or, if you are using TypeScript, add this to your `hardhat.config.ts`:
import "@nomicfoundation/hardhat-viem";
```

**Note:** you might want to pin viem-related dependencies because viem does not strictly follow semantic versioning for type changes. You can read more [here](https://hardhat.org/hardhat-runner/docs/advanced/using-viem#managing-types-and-version-stability).
**Note:** you might want to pin Viem-related dependencies because Viem does not strictly follow semantic versioning for type changes. You can read more [here](https://hardhat.org/hardhat-runner/docs/advanced/using-viem#managing-types-and-version-stability).

## Required plugins

Expand Down Expand Up @@ -232,6 +232,6 @@ await contract.write.method2([10, "arg2"]);

There are no additional steps you need to take for this plugin to work.

Install it and access viem through the Hardhat Runtime Environment anywhere you need it (tasks, scripts, tests, etc).
Install it and access Viem through the Hardhat Runtime Environment anywhere you need it (tasks, scripts, tests, etc).

Read the documentation on the [Hardhat Runtime Environment](https://hardhat.org/hardhat-runner/docs/advanced/hardhat-runtime-environment) to learn how to access the HRE in different ways to use viem from anywhere the HRE is accessible.
Read the documentation on the [Hardhat Runtime Environment](https://hardhat.org/hardhat-runner/docs/advanced/hardhat-runtime-environment) to learn how to access the HRE in different ways to use Viem from anywhere the HRE is accessible.

0 comments on commit 4c5839e

Please sign in to comment.