viem

viem

轻量级TypeScript接口库,优化以太坊开发体验

viem是一个轻量级TypeScript库,为以太坊开发提供简洁接口。它支持JSON-RPC API抽象、智能合约交互和钱包集成,并提供ABI处理和类型推断工具。viem使用原生BigInt,完全兼容TypeScript,针对主流开发环境进行优化。其清晰的API和文档简化了以太坊应用开发流程,提高开发效率。

viem以太坊TypeScriptJSON-RPC智能合约Github开源项目

[!重要] Viem 正在参与 Gitcoin Grants 第21轮。请考虑<a href="https://explorer.gitcoin.co/#/round/42161/389/73">支持该项目</a>。非常感谢。🙏

<br/> <p align="center"> <a href="https://viem.sh"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/viem/main/.github/gh-logo-dark.svg"> <img alt="viem 标志" src="https://yellow-cdn.veclightyear.com/835a84d5/645aa794-14c3-425a-901d-35c202ca51cb.svg" width="auto" height="60"> </picture> </a> </p> <p align="center"> 以太坊的TypeScript接口 <p> <p align="center"> <a href="https://www.npmjs.com/package/viem"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/viem?colorA=21262d&colorB=21262d&style=flat"> <img src="https://img.shields.io/npm/v/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="版本"> </picture> </a> <a href="https://app.codecov.io/gh/wevm/viem"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/codecov/c/github/wevm/viem?colorA=21262d&colorB=21262d&style=flat"> <img src="https://img.shields.io/codecov/c/github/wevm/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="代码覆盖率"> </picture> </a> <a href="https://github.com/wevm/viem/blob/main/LICENSE"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/l/viem?colorA=21262d&colorB=21262d&style=flat"> <img src="https://img.shields.io/npm/l/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="MIT 许可证"> </picture> </a> <a href="https://www.npmjs.com/package/viem"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/dm/viem?colorA=21262d&colorB=21262d&style=flat"> <img src="https://img.shields.io/npm/dm/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="每月下载量"> </picture> </a> <a href="https://bestofjs.org/projects/viem"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/endpoint?colorA=21262d&colorB=21262d&style=flat&url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=wevm%2Fviem%26since=daily"> <img src="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" alt="Best of JS"> </picture> </a> </p> <br>

特性

  • JSON-RPC API的抽象,使您的工作更加轻松
  • 智能合约交互的一流API
  • 与官方以太坊术语紧密对齐的语言
  • 导入您的浏览器扩展、WalletConnect或私钥钱包
  • 使用浏览器原生的BigInt,而不是大型BigNumber库
  • 用于处理ABI的实用工具(编码/解码/检查)
  • TypeScript就绪(从ABI和EIP-712类型化数据推断类型
  • AnvilHardhatGanache的一流支持
  • 分叉的以太坊网络上运行的测试套件

... 以及更多功能。

概述

// 1. 导入模块。 import { createPublicClient, http } from 'viem'; import { mainnet } from 'viem/chains'; // 2. 使用所需的链和传输设置您的客户端。 const client = createPublicClient({ chain: mainnet, transport: http(), }); // 3. 调用一个操作! const blockNumber = await client.getBlockNumber();

文档

前往文档阅读并了解更多关于viem的信息。

社区

查看以下地方获取更多viem相关内容:

支持

赞助商

<a href="https://paradigm.xyz"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/paradigm-dark.svg"> <img alt="paradigm 标志" src="https://yellow-cdn.veclightyear.com/835a84d5/bf9e1412-e0f7-4a3e-8a42-0dd30ed0bb1e.svg" width="auto" height="70"> </picture> </a> <br> <a href="https://twitter.com/family"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/family-dark.svg"> <img alt="family标志" src="https://yellow-cdn.veclightyear.com/835a84d5/1a8f44c0-6659-4906-8a78-841d8fb91689.svg" width="auto" height="50"> </picture> </a> <a href="https://twitter.com/context"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/context-dark.svg"> <img alt="context标志" src="https://yellow-cdn.veclightyear.com/835a84d5/44ebfb06-31a1-49f8-b649-601dd224cd76.svg" width="auto" height="50"> </picture> </a> <a href="https://walletconnect.com"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/walletconnect-dark.svg"> <img alt="WalletConnect标志" src="https://yellow-cdn.veclightyear.com/835a84d5/b63636d9-e208-4e85-9cac-3788fa4e18d8.svg" width="auto" height="50"> </picture> </a> <a href="https://zksync.io"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/zksync-dark.svg"> <img alt="ZKsync标志" src="https://yellow-cdn.veclightyear.com/835a84d5/92038fa3-7aab-42fb-aecc-8460fab2ac60.svg" width="auto" height="50"> </picture> </a> <a href="https://twitter.com/prtyDAO"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/partydao-dark.svg"> <img alt="PartyDAO标志" src="https://yellow-cdn.veclightyear.com/835a84d5/7ba1b206-282e-43fd-8782-993f442aff7d.svg" width="auto" height="50"> </picture> </a> <a href="https://dynamic.xyz"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/dynamic-dark.svg"> <img alt="Dynamic标志" src="https://yellow-cdn.veclightyear.com/835a84d5/7dcec5c1-b7ec-4bee-a807-48f3b03ee4fc.svg" width="auto" height="50"> </picture> </a> <a href="https://sushi.com"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/sushi-dark.svg"> <img alt="Sushi标志" src="https://yellow-cdn.veclightyear.com/835a84d5/b8cf0753-9a99-4e3d-8225-78642d2ffd3a.svg" width="auto" height="50"> </picture> </a> <a href="https://stripe.com"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/stripe-dark.svg"> <img alt="Stripe标志" src="https://yellow-cdn.veclightyear.com/835a84d5/5db8d589-61eb-4ee0-8eaa-6e8d4f7dd0a9.svg" width="auto" height="50"> </picture> </a> <a href="https://privy.io"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/privy-dark.svg"> <img alt="Privy标志" src="https://yellow-cdn.veclightyear.com/835a84d5/f43ee0ce-e8e3-47e3-9ee7-fcee0e842ec8.svg" width="auto" height="50"> </picture> </a> <a href="https://pancakeswap.finance"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/pancake-dark.svg"> <img alt="pancake标志" src="https://yellow-cdn.veclightyear.com/835a84d5/b07d9c68-037e-4c5f-ba7a-d35fe8180330.svg" width="auto" height="50"> </picture> </a> <a href="https://celo.org"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/celo-dark.svg"> <img alt="celo标志" src="https://yellow-cdn.veclightyear.com/835a84d5/8baa9f77-f825-4bd0-a133-533e3f81d5d9.svg" width="auto" height="50"> </picture> </a> <a href="https://pimlico.io"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/pimlico-dark.svg"> <img alt="pimlico标志" src="https://yellow-cdn.veclightyear.com/835a84d5/5c3f07f3-c6da-4dcd-8cdd-85537e5e0190.svg" width="auto" height="50"> </picture> </a> <a href="https://zora.co"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/zora-dark.svg"> <img alt="zora标志" src="https://yellow-cdn.veclightyear.com/835a84d5/c0ab6f4a-6d8d-4b53-a0fb-c27781f6d91f.svg" width="auto" height="50"> </picture> </a> <a href="https://lattice.xyz"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/lattice-dark.svg"> <img alt="lattice标志" src="https://yellow-cdn.veclightyear.com/835a84d5/8016c649-0a15-40e5-9528-0e0c6040c006.svg" width="auto" height="50"> </picture> </a> <a href="https://twitter.com/supafinance"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/supa-dark.svg"> <img alt="supa标志" src="https://yellow-cdn.veclightyear.com/835a84d5/8e2863a6-a361-40a7-addf-9abbf7ad4452.svg" width="auto" height="50"> </picture> </a> <a href="https://syndicate.io"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/syndicate-dark.svg"> <img alt="syndicate标志" src="https://yellow-cdn.veclightyear.com/835a84d5/ede24576-ce7c-4398-8f76-55640009028b.svg" width="auto" height="50"> </picture> </a> <a href="https://reservoir.tools"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/reservoir-dark.svg"> <img alt="reservoir标志" src="https://yellow-cdn.veclightyear.com/835a84d5/420fec3f-5709-4c23-9d0b-7f77f7ca08ed.svg" width="auto" height="50"> </picture> </a> <a href="https://brave.com"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/brave-dark.svg"> <img alt="brave标志" src="https://yellow-cdn.veclightyear.com/835a84d5/b75e7bc8-62c3-4db4-b283-e83c574caa4f.svg" width="auto" height="50"> </picture> </a> <a href="https://linea.build"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/linea-dark.svg"> <img alt="linea标志" src="https://yellow-cdn.veclightyear.com/835a84d5/fa1f5bc7-7884-46bb-9e8a-b13de1799042.svg" width="auto" height="50"> </picture> </a> <a href="https://uniswap.org"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/uniswap-dark.svg"> <img alt="uniswap标志" src="https://yellow-cdn.veclightyear.com/835a84d5/afef4042-ad9c-4513-8d25-9c4a595fecdb.svg" width="auto" height="50"> </picture> </a>

贡献

如果你有兴趣贡献,请在提交拉取请求之前阅读贡献文档

作者

许可证

MIT 许可证

编辑推荐精选

博思AIPPT

博思AIPPT

AI一键生成PPT,就用博思AIPPT!

博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。

热门AI工具AI办公办公工具智能排版AI生成PPT博思AIPPT海量精品模板AI创作
潮际好麦

潮际好麦

AI赋能电商视觉革命,一站式智能商拍平台

潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。

iTerms

iTerms

企业专属的AI法律顾问

iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。

SimilarWeb流量提升

SimilarWeb流量提升

稳定高效的流量提升解决方案,助力品牌曝光

稳定高效的流量提升解决方案,助力品牌曝光

Sora2视频免费生成

Sora2视频免费生成

最新版Sora2模型免费使用,一键生成无水印视频

最新版Sora2模型免费使用,一键生成无水印视频

Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

AI助手热门AI工具AI创作AI辅助写作讯飞绘文内容运营个性化文章多平台分发
TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

热门AI工具生产力协作转型TraeAI IDE
商汤小浣熊

商汤小浣熊

最强AI数据分析助手

小浣熊家族Raccoon,您的AI智能助手,致力于通过先进的人工智能技术,为用户提供高效、便捷的智能服务。无论是日常咨询还是专业问题解答,小浣熊都能以快速、准确的响应满足您的需求,让您的生活更加智能便捷。

imini AI

imini AI

像人一样思考的AI智能体

imini 是一款超级AI智能体,能根据人类指令,自主思考、自主完成、并且交付结果的AI智能体。

下拉加载更多