# @0xweb/hardhat 中文文档

规范地址：https://npmcn.com/package/%400xweb/hardhat/

版本：0\.1\.43
npm 元数据更新时间：2026-06-17T21:29:48.241Z
中文译文更新时间：2026-11-06T03:21:03.134Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%400xweb/hardhat
原文对照：https://npmcn.com/package/%400xweb/hardhat/?lang=original
项目主页：https://github.com/0xweb-org/hardhat#readme
源码仓库：https://github.com/0xweb-org/hardhat

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：255 kB，31 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：6 个
- peer 依赖：hardhat \>=2\.9\.3
- 首次发布：2022-04-20T23:48:00.093Z
- 最新版本发布：2026-06-17T21:29:47.962Z
- 近 30 天下载量：5787（2026-10-04 至 2026-11-02，npm 官方下载统计）
- 已发布版本数：32（近 12 个月 6 个）

## 中文简介

Hardhat 0xweb 插件

## 安装

```sh
npm install @0xweb/hardhat
```

也可以使用：`pnpm add @0xweb/hardhat`、`yarn add @0xweb/hardhat`、`bun add @0xweb/hardhat`

## README

# [`0xweb`](https://0xweb.org/) 用于 [哈达特](https://hardhat.org/)

* * *

[![npm version](https://badge.fury.io/js/@0xweb%2Fhardhat.svg)](https://badge.fury.io/js/@0xweb%2Fhardhat) [![CircleCI](https://circleci.com/gh/0xweb-org/hardhat.svg?style=svg)](https://circleci.com/gh/0xweb-org/hardhat)

插件生成 `0xWeb` 使区块链发展具有透明度.

> 我们用 [qq dequanto 图书馆](https://github.com/0xweb-org/dequanto) 课程

* * *

## [页:1](https://docs.0xweb.org/hardhat/info)

# 安装

### 自动安装依赖关系和配置

```bash
# install 0xweb
$ npm i 0xweb -g

# initialize 0xweb and hardhat project
$ 0xweb init --hardhat
```

# 编译

> `any/directory/Foo.sol`

```solidity
pragma solidity ^0.8.2;

contract Foo {
    string public name;

    function setName(string memory _name) public {
        name = _name;
    }
}
```

> 插件还增加了指定 `sources` 文件夹。 根据默认,这是 `/contracts/**.sol`

```bash
$ npx hardhat compile --sources ./any/directory/
```

# 用于地方发展

> `example.ts`

```ts
import { Foo } from '0xc/hardhat/Foo/Foo.ts'
import { HardhatProvider } from '@dequanto/hardhat/HardhatProvider'

// automatically deploys the contract to hardhat chain
const deployer = new HardhatProvider();
const foo = await deployer.deployClass<Foo>(Foo, { arguments: [ 'Hello' ] });

// write
const tx = await foo.setName('Hello world')
const receipt = await tx.wait();

// read
const text = await foo.name();

```

# 将已部署的合同用于任何链条

如果合同已经部署,将合同与地址初始化为正常类别。 如果合同被部署到其他链条上 -- -- 也将客户设定在构建器中

> `example.ts`

```ts
import { Foo } from '0xc/hardhat/Foo/Foo.ts'
import { EthWeb3Client } from '@dequanto/clients/EthWeb3Client'


const client =  new EthWeb3Client();
const foo = new Foo('0x12345...', client);

// write
const tx = await foo.setName('Hello world');
const receipt = tx.wait();
// read
const text = await foo.name();
```

# 其他参数

-   `npx hardhat compile --sources /foo/bar/qux` - 编译位于区域外的固态文件 `/contracts` 文件夹
-   `npx hardhat compile --artifacts /dist` - 设置文物定制文件夹(ABI JSONs和TS合同)
-   `npx hardhat compile --watch` - 汇编资料来源并等待重新汇编更改
-   `npx hardhat compile --package path/to/package/folder` - 您可以将您的工程分割成软件包, 通过命令将合同编译成软件包, 源将被搜索到该目录中, 并且将文物输出写入该目录
-   `npx hardhat compile --tsgen false` - 不要产生TS课程。 安装源目录中的所有合同 .
-   `npx hardhat compile --install TimelockController` - 只安装指定的艺术名称或 \*.sol路径 。 逗号分离.

* * *

## 常见问题

### @0xweb/hardhat 是什么？

Hardhat 0xweb 插件

### 如何安装 @0xweb/hardhat？

在项目目录运行 npm install @0xweb/hardhat，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：hardhat（\>=2\.9\.3）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @0xweb/hardhat 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/0xweb\_\_hardhat 是否存在。

### @0xweb/hardhat 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @0xweb/hardhat 可以商用吗？

@0xweb/hardhat 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @0xweb/hardhat 的下载量有多少？

根据 npm 官方下载统计，@0xweb/hardhat 在 2026/10/04 – 2026/11/02 这 30 天内被下载 5,787 次，日均约 193 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @0xweb/hardhat 还在维护吗？

最新版本 0\.1\.43 发布于 2026/06/18（4 个月前）；至今共发布 32 个版本，其中过去 12 个月发布了 6 个；首次发布于 2022/04/21。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

