Documentation for using Viem, a TypeScript interface for EVM-compatible blockchains. This page covers installation, setup, and various functionalities such as reading and writing blockchain data and interacting with smart contracts on Base.
base
as the chain when creating a Client.To use Base Sepolia (testnet), replace base
with baseSepolia
.eth_blockNumber
, eth_getBalance
, etc.)
For example, you can use the getBlockNumber
client method to get the latest block:
createWalletClient
) and specify an Account
to use.
eth_requestAccounts
) to get an Account, viem provides various helper methods for creating an Account
, including: privateKeyToAccount
, mnemonicToAccount
, and hdKeyToAccount
.To use Base Sepolia (testnet), replace base
with baseSepolia
.Contract
instance using getContract
and passing it the contract ABI, contract address, and Public and/or Wallet Client:
CONTRACT_ADDRESS
is the address of the deployed contract.