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提供零门槛AI创作工具,独创GETI法则帮助用户精准定义音乐风格,AI润色功能支持自动优化作品质感。音述AI支持交流讨论、二次创作与价值变现。针对中文用户的语言习惯与文化背景进行专门优化,支持国风融合、C-pop等本土音乐标签,让技术更好地承载人文表达。

QoderWork

QoderWork

阿里Qoder团队推出的桌面端AI智能体

QoderWork 是阿里推出的本地优先桌面 AI 智能体,适配 macOS14+/Windows10+,以自然语言交互实现文件管理、数据分析、AI 视觉生成、浏览器自动化等办公任务,自主拆解执行复杂工作流,数据本地运行零上传,技能市场可无限扩展,是高效的 Agentic 生产力办公助手。

lynote.ai

lynote.ai

一站式搞定所有学习需求

不再被海量信息淹没,开始真正理解知识。Lynote 可摘要 YouTube 视频、PDF、文章等内容。即时创建笔记,检测 AI 内容并下载资料,将您的学习效率提升 10 倍。

AniShort

AniShort

为AI短剧协作而生

专为AI短剧协作而生的AniShort正式发布,深度重构AI短剧全流程生产模式,整合创意策划、制作执行、实时协作、在线审片、资产复用等全链路功能,独创无限画布、双轨并行工业化工作流与Ani智能体助手,集成多款主流AI大模型,破解素材零散、版本混乱、沟通低效等行业痛点,助力3人团队效率提升800%,打造标准化、可追溯的AI短剧量产体系,是AI短剧团队协同创作、提升制作效率的核心工具。

seedancetwo2.0

seedancetwo2.0

能听懂你表达的视频模型

Seedance two是基于seedance2.0的中国大模型,支持图像、视频、音频、文本四种模态输入,表达方式更丰富,生成也更可控。

nano-banana纳米香蕉中文站

nano-banana纳米香蕉中文站

国内直接访问,限时3折

输入简单文字,生成想要的图片,纳米香蕉中文站基于 Google 模型的 AI 图片生成网站,支持文字生图、图生图。官网价格限时3折活动

扣子-AI办公

扣子-AI办公

职场AI,就用扣子

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

堆友

堆友

多风格AI绘画神器

堆友平台由阿里巴巴设计团队创建,作为一款AI驱动的设计工具,专为设计师提供一站式增长服务。功能覆盖海量3D素材、AI绘画、实时渲染以及专业抠图,显著提升设计品质和效率。平台不仅提供工具,还是一个促进创意交流和个人发展的空间,界面友好,适合所有级别的设计师和创意工作者。

图像生成AI工具AI反应堆AI工具箱AI绘画GOAI艺术字堆友相机AI图像热门
码上飞

码上飞

零代码AI应用开发平台

零代码AI应用开发平台,用户只需一句话简单描述需求,AI能自动生成小程序、APP或H5网页应用,无需编写代码。

Vora

Vora

免费创建高清无水印Sora视频

Vora是一个免费创建高清无水印Sora视频的AI工具

下拉加载更多