viem Integration
Integrate EVM blockchains using viem for TypeScript/JavaScript applications.
Quick Decision Guide
Building...
Use This
Node.js script/backend
viem with http transport
React/Next.js frontend
wagmi hooks (built on viem)
Real-time event monitoring
viem with webSocket transport
Browser wallet integration
wagmi or viem custom transport
Installation
npm install viem
npm install wagmi viem @tanstack/react-query
Core Concepts
Clients
viem uses two client types:
Client
Purpose
Example Use
PublicClient
Read-only operations
Get balances, read contracts, fetch logs
WalletClient
Write operations
Send transactions, sign messages
Transports
Transport
Use Case
http()
Standard RPC calls (most common)
webSocket()
Real-time event subscriptions
custom()
Browser wallets (window.ethereum)
Chains
viem includes 50+ chain definitions. Import from viem/chains:
import { mainnet, arbitrum, optimism, base, polygon } from 'viem/chains' ;
Input Validation Rules
Before interpolating ANY user-provided value into generated TypeScript code:
Ethereum addresses : MUST match ^0x[a-fA-F0-9]{40}$ β use viem's isAddress() for validation
Chain IDs : MUST be from viem's supported chain definitions
Private keys : MUST NEVER be hardcoded β always use process.env.PRIVATE_KEY with runtime validation
RPC URLs : MUST use https:// or wss:// protocols only
ABI inputs : Validate types match expected Solidity types before encoding
Quick Start Examples
Read Balance
import { createPublicClient, http, formatEther } from 'viem' ;
import { mainnet } from 'viem/chains' ;
const client = createPublicClient ( {
chain: mainnet,
transport: http ( ) ,
} ) ;
const balance = await client. getBalance ( {
address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' ,
} ) ;
console . log ( ` Balance: ${ formatEther ( balance) } ETH ` ) ;
Read Contract
import { createPublicClient, http, parseAbi } from 'viem' ;
import { mainnet } from 'viem/chains' ;
const client = createPublicClient ( {
chain: mainnet,
transport: http ( ) ,
} ) ;
const abi = parseAbi ( [
'function balanceOf(address) view returns (uint256)' ,
'function decimals() view returns (uint8)' ,
] ) ;
const balance = await client. readContract ( {
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' ,
abi,
functionName: 'balanceOf' ,
args: [ '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' ] ,
} ) ;
Send Transaction
import { createWalletClient, http, parseEther } from 'viem' ;
import { privateKeyToAccount } from 'viem/accounts' ;
import { mainnet } from 'viem/chains' ;
const account = privateKeyToAccount ( process. env. PRIVATE_KEY as ` 0x ${ string } ` ) ;
const client = createWalletClient ( {
account,
chain: mainnet,
transport: http ( ) ,
} ) ;
const hash = await client. sendTransaction ( {
to: '0x...' ,
value: parseEther ( '0.1' ) ,
} ) ;
console . log ( ` Transaction hash: ${ hash} ` ) ;
Write to Contract
import { createWalletClient, createPublicClient, http, parseAbi, parseUnits } from 'viem' ;
import { privateKeyToAccount } from 'viem/accounts' ;
import { mainnet } from 'viem/chains' ;
const account = privateKeyToAccount ( process. env. PRIVATE_KEY as ` 0x ${ string } ` ) ;
const walletClient = createWalletClient ( {
account,
chain: mainnet,
transport: http ( ) ,
} ) ;
const publicClient = createPublicClient ( {
chain: mainnet,
transport: http ( ) ,
} ) ;
const abi = parseAbi ( [ 'function transfer(address to, uint256 amount) returns (bool)' ] ) ;
const { request } = await publicClient. simulateContract ( {
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' ,
abi,
functionName: 'transfer' ,
args: [ '0x...' , parseUnits ( '100' , 6 ) ] ,
account,
} ) ;
const hash = await walletClient. writeContract ( request) ;
const receipt = await publicClient. waitForTransactionReceipt ( { hash } ) ;
console . log ( ` Confirmed in block ${ receipt. blockNumber} ` ) ;
Reference Documentation
For deeper coverage of specific topics:
Topic
Reference File
Client setup, transports, chains
Clients & Transports
Reading blockchain data
Reading Data
Sending transactions
Writing Transactions
Private keys, HD wallets
Accounts & Keys
ABI handling, multicall
β
Make data-driven prioritization decisions faster
Stakeholder Communication Draft PRDs, status updates, and stakeholder presentations
Example
Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement
β Save 3-5 hours/week on communication overhead
Implementation Guide Prerequisites
βΊ Claude Desktop or compatible AI client βΊ Access to product documentation and roadmap tools (Jira, Notion, etc.) βΊ Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.) βΊ Stakeholder contact information and communication channels Time Estimate
30-60 minutes to see productivity improvements
Steps
1 Install product management skill 2 Start with user story generation for known feature 3 Progress to competitive analysis: research 2-3 competitors 4 Use for roadmap prioritization: apply RICE/ICE scoring 5 Draft stakeholder communications and refine based on feedback 6 Build template library for recurring PM tasks 7 Share effective prompts with product team Common Pitfalls
β Not validating competitive researchβverify facts before sharing β Accepting user stories without involving engineering team β Over-relying on frameworks without qualitative judgment β Not customizing outputs to company culture and communication style β Skipping stakeholder validation of generated requirements Best Practices β Do
+ Validate research and competitive analysis with real data + Collaborate with engineering when generating technical requirements + Customize frameworks and templates to your company context + Use skill for first drafts, refine with stakeholder input + Document successful prompt patterns for PM tasks + Combine AI efficiency with human judgment and intuition β Don't
β Don't publish competitive analysis without fact-checking β Don't finalize user stories without engineering review β Don't make prioritization decisions solely on AI scoring β Don't skip customer validation of generated requirements β Don't ignore company-specific context and culture π‘ Pro Tips
β
Provide context: company goals, constraints, customer feedback β
Ask for alternatives: 'Show 3 ways to prioritize this roadmap' β
Request stakeholder-specific formatting: 'Executive summary vs. engineering spec' β
Use skill for 70% generation + 30% customization to company needs When to Use This β Use when
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
β Avoid when
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path 1 Basic: user stories, feature specs, status updates 2 Intermediate: competitive analysis, prioritization frameworks, PRDs 3 Advanced: product strategy, go-to-market planning, OKR setting 4 Expert: product vision, market positioning, business model innovation Reviews 4.8 β
β
β
β
β
61 reviews
D
Dhruvi Jain β
β
β
β
β
Dec 24, 2024
viem-integration reduced setup friction for our internal harness; good balance of opinion and flexibility.
O
Omar Gonzalez β
β
β
β
β
Dec 24, 2024
viem-integration is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
K
Kwame Wang β
β
β
β
β
Dec 24, 2024
Registry listing for viem-integration matched our evaluation β installs cleanly and behaves as described in the markdown.
N
Noah Torres β
β
β
β
β
Dec 8, 2024
Solid pick for teams standardizing on skills: viem-integration is focused, and the summary matches what you get after install.
Z
Zaid Khan β
β
β
β
β
Nov 27, 2024
viem-integration is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
O
Oshnikdeep β
β
β
β
β
Nov 15, 2024
I recommend viem-integration for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
K
Kwame Gonzalez β
β
β
β
β
Nov 15, 2024
Solid pick for teams standardizing on skills: viem-integration is focused, and the summary matches what you get after install.
A
Ama Thompson β
β
β
β
β
Nov 15, 2024
Useful defaults in viem-integration β fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
Z
Zaid Martinez β
β
β
β
β
Oct 18, 2024
Keeps context tight: viem-integration is the kind of skill you can hand to a new teammate without a long onboarding doc.
G
Ganesh Mohane β
β
β
β
β
Oct 6, 2024
Useful defaults in viem-integration β fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
showing 1-10 of 61
prev 1 / 7 next
Discussion Comments β not star reviews No comments yet β start the thread.