# viem — card for AI agents

TypeScript interface for Ethereum with type-safe interactions.

Category: Crypto and web3 · npm package `viem` · latest version 2.57.14 (checked 2026-11-01)
Install: `npm install viem`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## viem
- Create a Client with an explicit `chain` (from `viem/chains`) and `transport`, then call Actions on it.
- In production, pass an authenticated RPC URL to `http(...)`. Without a URL, viem uses a public RPC provider.
- Use a Public Client for reads such as `readContract`, `getBalance` and `getBlockNumber`. A Wallet Client does not support public actions.
- Pass contract `args` as a positional array in ABI order, not as an object keyed by parameter name.
- Expect an array when a contract function returns several values. Only explicitly typed tuples (structs) decode to objects.
- Use native `bigint` literals such as `100n` for amounts.
- When signing through a JSON-RPC Account (browser extension, WalletConnect), handle the case where the wallet rejects the request. A signature is not guaranteed.

## Docs written for agents
- [llms.txt (index of the docs)](https://viem.sh/llms.txt)

## What it is
- viem is a TypeScript library for talking to Ethereum. The docs describe it as providing "low-level stateless primitives for interacting with Ethereum". The maintainers position it as "an alternative to ethers.js and web3.js". The repository was created in July 2022 and is MIT licensed. The latest release listed is viem@2.57.4.
- You start by creating a Client. You give it a Chain, such as `mainnet` from `viem/chains`, and a Transport, such as `http()`. Then you call Actions on the Client, for example `getBlockNumber()`. The docs list Public, Wallet and Test clients. They also list HTTP, WebSocket, IPC, Fallback and custom transports.
- The authors built viem because, as authors of the React library wagmi, they "struggled to work with the existing low-level TypeScript Ethereum libraries". The site pitches it for building "apps &amp; libraries" from lightweight, composable and type-safe modules.

## Caveats
- More code per call, by design: The authors admit the APIs can be wordier than in other libraries. They call this a trade-off in favour of flexible building blocks.
- Contract args are positional arrays: You pass `args` as a tuple, not an object, even when every input is named in Solidity. The FAQ says TypeScript doesn't support dynamic named tuples yet. Once it does, viem will add them so parameter names show up in your editor.
- Multi-value returns come back as arrays: A function that returns several named values gives you an array of decoded values, not an object. Only explicitly typed tuples, such as structs, map to objects.
- Wallet Client has no public actions: Methods such as `eth_call` and `eth_getLogs` are public actions, and the Wallet Client doesn't support them. The FAQ explains that wallet providers may not provide most "node"/"public" RPC methods.
- Falls back to a public RPC: If you call `http()` without a URL, viem uses a public RPC provider. The docs strongly recommend an authenticated provider URL in production.

## Numbers (AgentGid data)
- Gid Score: 72.9 (#277 of all tools, 1 of 155 in its category)
- Used in 47 public projects set up for AI coding agents (0.8%)
- Downloads last week: 10,749,623 (as of 2026-11-24), +49.2% over 4 weeks
- GitHub stars: 3,632 (as of 2026-11-24)
- Last push: 2026-11-24

## Often used with
TanStack Query 38.3%, wagmi 36.2%, Zod 59.6%, TypeScript 87.2%, dotenv 42.6%, React 59.6%

## Checked alternatives (same job)
- ethers.js: https://agentgid.com/tools/ethers/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/viem/
- Homepage: https://viem.sh
- Repository: https://github.com/wevm/viem
- Source: https://github.com/wevm/viem
- Source: https://github.com/wevm/viem/releases
- Source: https://viem.sh
- Source: https://viem.sh/docs/introduction
- Source: https://viem.sh/docs/getting-started
- Source: https://viem.sh/docs/faq

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
