# @aztec/viem 中文文档

规范地址：https://npmcn.com/package/%40aztec/viem/

版本：2\.38\.3
npm 元数据更新时间：2026-09-21T13:17:37.754Z
中文译文更新时间：2026-11-07T14:18:56.755Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40aztec/viem
原文对照：https://npmcn.com/package/%40aztec/viem/?lang=original
项目主页：https://viem.sh/
源码仓库：https://github.com/wevm/viem

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

- 包体积（解压后）：17.3 MB，8743 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：8 个
- peer 依赖：typescript \>=5\.0\.4
- 首次发布：2025-11-25T17:27:55.635Z
- 最新版本发布：2026-09-18T15:44:03.574Z
- 近 30 天下载量：21779（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：2（近 12 个月 2 个）

## 中文简介

Ethereum 的脚本接口

## 安装

```sh
npm install @aztec/viem
```

也可以使用：`pnpm add @aztec/viem`、`yarn add @aztec/viem`、`bun add @aztec/viem`

## README

  

[![viem logo](https://raw.githubusercontent.com/wevm/viem/main/.github/gh-logo-light.svg)](https://viem.sh/)

Ethereum 的脚本接口

 [![Version](https://img.shields.io/npm/v/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat)](https://www.npmjs.com/package/viem)[![Code coverage](https://img.shields.io/codecov/c/github/wevm/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat) ](https://app.codecov.io/gh/wevm/viem)[![MIT License](https://img.shields.io/npm/l/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat) ](https://github.com/wevm/viem/blob/main/LICENSE)[![Downloads per month](https://img.shields.io/npm/dm/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat) ](https://www.npmjs.com/package/viem)[![Best of JS](https://img.shields.io/endpoint?colorA=f6f8fa&colorB=f6f8fa&style=flat&url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=wevm%2Fviem%26since=daily)](https://bestofjs.org/projects/viem)

  

## 特征

-   引文摘自 [JSON-RPC API (英语)](https://ethereum.org/en/developers/docs/apis/json-rpc/) 让你的生活变得轻松
-   用于互动的一等 API [智能合同](https://ethereum.org/en/glossary/#smart-contract)
-   语言与官方语言紧密一致 [术语](https://ethereum.org/en/glossary/)
-   导入您的浏览器扩展、 钱包连接或私人密钥钱包
-   浏览器本地 [大点](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt),而不是大型大数字库
-   工作用品 [ABIs 函数](https://ethereum.org/en/glossary/#abi) (编码/解码/检查)
-   类型脚本准备就绪( T)[推断类型](https://viem.sh/docs/typescript) 从ABIs和EIP-712型数据)
-   对 [安维尔](https://book.getfoundry.sh/), (中文(简体) ), [哈达特](https://hardhat.org/) 打开 [甘纳切](https://trufflesuite.com/ganache/)
-   测试套件运行对 [准备](https://ethereum.org/en/glossary/#fork) 伊特鲁姆网络

还有更多.

## 概览

```ts
// 1. Import modules.
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';

// 2. Set up your client with desired chain & transport.
const client = createPublicClient({
  chain: mainnet,
  transport: http(),
});

// 3. Consume an action!
const blockNumber = await client.getBlockNumber();
```

## 文档

[前往文件处](https://viem.sh/docs/getting-started) 阅读和学习更多关于viem.

## 社区

请检查access-date=中的日期值 (帮助) 以下位置查看更多viem相关内容:

-   跟随 [@ wevm dev](https://twitter.com/wevm_dev), (中文(简体) ), [页:1](https://twitter.com/_jxom),以及 [@awkweb](https://twitter.com/awkweb) 在Twitter上进行项目更新
-   请加入 [关于GitHub的讨论](https://github.com/wevm/viem/discussions)
-   [分享您的项目/组织](https://github.com/wevm/viem/discussions/104) 使用viem系统

## 支助

-   [GitHub 赞助商](https://github.com/sponsors/wevm?metadata_campaign=docs_support)
-   [Gitcoin 格兰特](https://wagmi.sh/gitcoin)
-   [韦文斯](https://etherscan.io/name-lookup-search?id=wevm.eth)

## 发起人

 [![paradigm logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/paradigm-light.svg)](https://paradigm.xyz/)[![ithaca logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/ithaca-light.svg)](https://ithaca.xyz/)  
 [![family logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/family-light.svg)](https://twitter.com/family)[![context logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/context-light.svg) ](https://twitter.com/context)[![WalletConnect logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/walletconnect-light.svg) ](https://walletconnect.com/)[![PartyDAO logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/partydao-light.svg) ](https://twitter.com/prtyDAO)[![Dynamic logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/dynamic-light.svg) ](https://dynamic.xyz/)[![Sushi logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/sushi-light.svg) ](https://sushi.com/)[![Stripe logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/stripe-light.svg) ](https://stripe.com/)[![Privy logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/privy-light.svg) ](https://privy.io/)[![pancake logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/pancake-light.svg) ](https://pancakeswap.finance/)[![celo logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/celo-light.svg) ](https://celo.org/)[![rainbow logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/rainbow-light.svg) ](https://rainbow.me/)[![pimlico logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/pimlico-light.svg) ](https://pimlico.io/)[![zora logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/zora-light.svg) ](https://zora.co/)[![lattice logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/lattice-light.svg) ](https://lattice.xyz/)[![supa logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/supa-light.svg) ](https://twitter.com/supafinance)[![ZKsync logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/zksync-light.svg) ](https://zksync.io/)[![syndicate logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/syndicate-light.svg) ](https://syndicate.io/)[![reservoir logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/reservoir-light.svg) ](https://reservoir.tools/)[![linea logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/linea-light.svg) ](https://linea.build/)[![uniswap logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/uniswap-light.svg) ](https://uniswap.org/)[![biconomy logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/biconomy-light.svg) ](https://biconomy.io/)[![thirdweb logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/thirdweb-light.svg) ](https://thirdweb.com/)[![polymarket logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/polymarket-light.svg) ](https://polymarket.com/)[![routescan logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/routescan-light.svg) ](https://routescan.io/)[![sequence logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/sequence-light.svg) ](https://sequence.xyz/)[![gemini logo](https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/gemini-light.svg)](https://gemini.com/)

## 捐款

如果你有兴趣捐款,请阅读 [提供文件](https://npmcn.com/.github/CONTRIBUTING.md) **在提交拉动请求之前**。 。 。 .

## 作者数

-   [@ jxom](https://github.com/jxom) (jxom.eth,第1行), [微博](https://twitter.com/_jxom)(中文(简体) )
-   [@tmm (英语)](https://github.com/tmm) (awkweb.eth, 维基语录链接:名人名言), [微博](https://twitter.com/awkweb)(中文(简体) )

## 许可证

[麻省理工学院](https://npmcn.com/LICENSE) 许可证

  
  
[![Powered by Vercel](https://www.datocms-assets.com/31049/1618983297-powered-by-vercel.svg)](https://vercel.com/?utm_source=wevm&utm_campaign=oss)

## 常见问题

### @aztec/viem 是什么？

Ethereum 的脚本接口

### 如何安装 @aztec/viem？

在项目目录运行 npm install @aztec/viem，或使用 pnpm add / yarn add / bun add。

### @aztec/viem 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @aztec/viem 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @aztec/viem 可以商用吗？

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

### @aztec/viem 的下载量有多少？

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

### @aztec/viem 还在维护吗？

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

