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 许可证

编辑推荐精选

商汤小浣熊

商汤小浣熊

最强AI数据分析助手

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

imini AI

imini AI

像人一样思考的AI智能体

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

Keevx

Keevx

AI数字人视频创作平台

Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。

即梦AI

即梦AI

一站式AI创作平台

提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作

扣子-AI办公

扣子-AI办公

AI办公助手,复杂任务高效处理

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

TRAE编程

TRAE编程

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

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

AI工具TraeAI IDE协作生产力转型热门
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

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

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

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
下拉加载更多