viem
TypeScript interface for Ethereum with type-safe interactions.
3. Used by agents' projects
Dependency in 47 public GitHub projects set up for AI coding agents that we scanned (0.8%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
viem.sh/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What viem does
viem was written by the wagmi authors as a low-level, stateless TypeScript layer for Ethereum. It deliberately mirrors the chain's own shapes, such as positional contract arguments, array return values and separate Wallet and Public clients, even where that costs some convenience.
viem popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How viem is used
- viem is a dependency in 47 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.0% of the 4,867 JavaScript/TypeScript ones), #1 of 155 in crypto and web3.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,920; those are left out of every share on this page.
- The most used alternative in our scan is ethers.js (30 projects).
- Projects that use it most often also use TanStack Query (38.3%), wagmi (36.2%), Zod (59.6%).
By coding agent
Often used with
viem in practice
Strengths
The docs say viem is tree-shakable. They argue that end users should not have to download "a module of over 100kB" just to interact with Ethereum.
The site lists utilities for encoding, decoding and inspecting ABIs. It says viem can infer types from ABIs and EIP-712 Typed Data. Amounts use the browser's native <code>BigInt</code> instead of a BigNumber library.
The maintainers say stability matters because many organizations depend on wagmi. Their test suite runs against a forked Ethereum node, and they aim for complete test coverage.
viem does not use a single "Signer". A Local Account signs directly with its private key. A JSON-RPC Account asks a wallet, such as a browser extension or WalletConnect, to sign, and the wallet can refuse that request.
Watch out for
The authors admit the APIs can be wordier than in other libraries. They call this a trade-off in favour of flexible building blocks.
You pass <code>args</code> 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.
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.
Read the latest block number
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
const client = createPublicClient ({
chain: mainnet,
transport: http (),
})
const blockNumber = await client. getBlockNumber ()More about viem
Funding
- GitHub Sponsors: https://github.com/wevm
- Own page: https://drips.network/wevm.eth
- 16 GitHub sponsors
Packages around it
- wagmi: React Hooks for Ethereum, same authors
- @tanstack/react-query: TanStack Query
- ethers: Alternative; docs have a v5 migration guide
- @rainbow-me: RainbowKit
- next: Next.js
Alternatives
viem This page
Complete Ethereum library for building dapps, wallets and blockchain tools.
Get started
Install it.
npm install viemRules for your agent
## 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.