API Reference
The client factories and action families that make up viem's public surface.
Path: api-reference
Third-party documentation. This is independently authored analysis of the public Viem codebase — not the official docs, and not reviewed or endorsed by the Viem team.
API Reference
Viem's surface area is intentionally small: two client factories, action families per client, and a utilities module.
Client factories
createPublicClient()— read-side client.createWalletClient()— write-capable client.createTestClient()— Anvil/Ganache-style dev-node control (mining, snapshots, impersonation).
Core actions
- Chain state:
getBlock,getTransaction,getTransactionReceipt,getBlockNumber,getGasPrice. - Accounts:
getBalance,getNonce,getBytecode,getStorageAt. - Contracts:
readContract,simulateContract,writeContract,watchContractEvent. - Writes:
sendTransaction,sendRawTransaction,waitForTransactionReceipt.
Utilities
- Units:
parseEther,parseUnits,formatEther,formatUnits. - ABI:
encodeFunctionData,decodeFunctionResult,encodeEventTopics,decodeErrorResult. - Data:
toHex/fromHex,isAddress/getAddress(checksummed),keccak256,hashMessage.
Accounts
privateKeyToAccount, generateMnemonic, mnemonicToAccount — all returning the shared account interface (sign, signMessage, signTypedData, address).
Interface
Interface
typescript
function createPublicClient({ chain, transport, account? }): PublicClientfunction createWalletClient({ chain, transport, account }): WalletClient// Read actions (PublicClient)client.getBlockNumber(): bigintclient.getBalance({ address }): bigintclient.readContract({ address, abi, functionName, args? })client.watchContractEvent({ address, abi, eventName, onLogs })// Write actions (WalletClient)wallet.sendTransaction({ to, value?, data? }): Hashwallet.writeContract({ address, abi, functionName, args? }): Hashwallet.signMessage({ message }): Hex// UtilitiesparseEther('1.5'): bigint // ether string -> wei bigintformatUnits(value, decimals): stringencodeFunctionData / decodeFunctionResult
STATUSinterface
