MCPcopy Index your code
hub / github.com/wevm/viem

github.com/wevm/viem @2.54.3 sqlite

repository ↗ · DeepWiki ↗ · release 2.54.3 ↗
2,129 symbols 9,792 edges 2,144 files 29 documented · 1%
README

    <img alt="viem logo" src="https://raw.githubusercontent.com/wevm/viem/main/.github/gh-logo-light.svg" width="auto" height="60">

TypeScript Interface for Ethereum

  <img src="https://img.shields.io/npm/v/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Version">

  <img src="https://img.shields.io/codecov/c/github/wevm/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Code coverage">

  <img src="https://img.shields.io/npm/l/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="MIT License">

  <img src="https://img.shields.io/npm/dm/viem?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Downloads per month">

  <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">

Features

  • Abstractions over the JSON-RPC API to make your life easier
  • First-class APIs for interacting with Smart Contracts
  • Language closely aligned to official Ethereum terminology
  • Import your Browser Extension, WalletConnect or Private Key Wallet
  • Browser native BigInt, instead of large BigNumber libraries
  • Utilities for working with ABIs (encoding/decoding/inspection)
  • TypeScript ready (infer types from ABIs and EIP-712 Typed Data)
  • First-class support for Anvil, Hardhat & Ganache
  • Test suite running against forked Ethereum network

... and a lot more.

Overview

// 1. Import modules.
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';

// 2. Set up your client with desired chain & transport.
const client = createPublicClient({
  chain: mainnet,
  transport: http(),
});

// 3. Consume an action!
const blockNumber = await client.getBlockNumber();

Documentation

Head to the documentation to read and learn more about viem.

Community

Check out the following places for more viem-related content:

Support

Sponsors

<img alt="paradigm logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/paradigm-light.svg" width="auto" height="70">

<img alt="tempo logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/tempo-light.svg" width="auto" height="70">

<img alt="family logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/family-light.svg" width="auto" height="50">

<img alt="context logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/context-light.svg" width="auto" height="50">

<img alt="PartyDAO logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/partydao-light.svg" width="auto" height="50">

<img alt="Dynamic logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/dynamic-light.svg" width="auto" height="50">

<img alt="Sushi logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/sushi-light.svg" width="auto" height="50">

<img alt="Stripe logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/stripe-light.svg" width="auto" height="50">

<img alt="Privy logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/privy-light.svg" width="auto" height="50">

<img alt="pancake logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/pancake-light.svg" width="auto" height="50">

<img alt="pimlico logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/pimlico-light.svg" width="auto" height="50">

<img alt="zora logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/zora-light.svg" width="auto" height="50">

<img alt="syndicate logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/syndicate-light.svg" width="auto" height="50">

<img alt="relay logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/relay-light.svg" width="auto" height="50">

<img alt="polymarket logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/polymarket-light.svg" width="auto" height="50">

<img alt="sequence logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/sequence-light.svg" width="auto" height="50">

<img alt="web3auth logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/web3auth-light.svg" width="auto" height="50">

Contributing

If you're interested in contributing, please read the contributing docs before submitting a pull request.

Authors

License

MIT License

Powered by Vercel

Extension points exported contracts — how you extend this code

Register (Interface)
(no doc)
src/types/register.ts
InterfaceDefinition (Interface)
(no doc)
scripts/generateTempoAbis.ts
Window (Interface)
(no doc)
src/types/window.ts
ProcessedInterface (Interface)
(no doc)
scripts/generateTempoAbis.ts

Core symbols most depended-on inside this repo

defineChain
called by 749
src/utils/chain/defineChain.ts
parseEther
called by 687
src/utils/unit/parseEther.ts
mine
called by 528
src/actions/test/mine.ts
wait
called by 470
src/utils/wait.ts
writeContract
called by 364
src/actions/wallet/writeContract.ts
privateKeyToAccount
called by 350
src/accounts/privateKeyToAccount.ts
parseUnits
called by 293
src/utils/unit/parseUnits.ts
getAddress
called by 288
src/account-abstraction/accounts/implementations/toSoladySmartAccount.ts

Shape

Function 1,497
Class 418
Method 210
Interface 4

Languages

TypeScript100%

Modules by API surface

src/account-abstraction/errors/bundler.ts108 symbols
src/errors/rpc.ts87 symbols
src/errors/abi.ts78 symbols
src/tempo/actions/token.ts53 symbols
src/errors/transaction.ts37 symbols
src/errors/node.ts36 symbols
src/tempo/actions/dex.ts30 symbols
src/utils/cursor.ts27 symbols
src/errors/encoding.ts24 symbols
scripts/generateTokenlist.ts23 symbols
src/tempo/actions/accessKey.ts22 symbols
src/tempo/actions/receivePolicy.ts21 symbols

Dependencies from manifests, versioned

@arethetypeswrong/cli0.18.2 · 1×
@ark/attest0.56.0 · 1×
@biomejs/biome2.2.4 · 1×
@changesets/changelog-github0.4.8 · 1×
@changesets/cli2.29.7 · 1×
@ethereumjs/rlp5.0.2 · 1×
@noble/curves1.9.1 · 1×
@noble/hashes1.8.0 · 1×
@paulmillr/trusted-setups0.1.2 · 1×
@pimlico/alto0.0.18 · 1×
@playwright/test1.59.1 · 1×
@remix-run/node-fetch-server0.12.0 · 1×

For agents

$ claude mcp add viem \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact