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小说写作助手,一站式润色、改写、扩写

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

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
Trae

Trae

字节跳动发布的AI编程神器IDE

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

AI工具TraeAI IDE协作生产力转型热门
问��小白

问小白

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

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

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

Transly

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

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

讯飞智文

讯飞智文

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

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

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

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

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

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

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

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多