Supporting packages
These supporting packages provide contract fixtures, chain presets, predeploy helpers, ABI/hex utilities, typed error classes, and remote viem extensions.
@tevm/contract
Section titled “@tevm/contract”Umbrella subpath: tevm/contract (also re-exported from tevm).
Exports
Section titled “Exports”createContract(params)— build a typedContractinstance (abi,humanReadableAbi,bytecode,deployedBytecode,withAddress(),deploy(),read.*,write.*,events.*) from an ABI or human-readable ABI.- Bundled fixtures for tests and examples:
SimpleContract,ERC20,ERC721,ErrorContract,AdvancedContract. - Types:
Contract,CreateContractParams,CreateContractFn,ReadActionCreator,WriteActionCreator,EventActionCreator.
import { createContract, createMemoryClient, PREFUNDED_ACCOUNTS } from 'tevm'
const Counter = createContract({ name: 'Counter', humanReadableAbi: [ 'function count() view returns (uint256)', 'function increment()', ],})
const bound = Counter.withAddress('0x0000000000000000000000000000000000000123')console.log(bound.read.count())See also: contract.tevm.sh.
@tevm/common
Section titled “@tevm/common”Umbrella subpath: tevm/common.
Exports
Section titled “Exports”export * from 'viem/chains'(e.g.mainnet,optimism,base,arbitrum,sepolia,foundry).tevmDefault— alias forfoundry(id: 31337).- Type:
Common(alias for viem’sChain).
import { mainnet, optimism, tevmDefault } from 'tevm/common'@tevm/predeploys
Section titled “@tevm/predeploys”Umbrella subpath: tevm/predeploys.
Exports
Section titled “Exports”definePredeploy({ address, contract })— pair aContractinstance with a fixed deployment address.- Types:
Predeploy,DefinePredeployFn.
@tevm/utils
Section titled “@tevm/utils”Umbrella subpath: tevm/utils (also re-exported from tevm).
Exports
Section titled “Exports”- Prefunded test accounts:
PREFUNDED_ACCOUNTS,PREFUNDED_PRIVATE_KEYS,PREFUNDED_PUBLIC_KEYS,PREFUNDED_SEED. - Hardhat
console.logdecoder:decodeHardhatConsoleLog,HARDHAT_CONSOLE_ADDRESS. - Viem & ABI utilities:
parseAbi,formatAbi,encodeFunctionData,decodeFunctionResult,encodeDeployData,decodeEventLog,decodeErrorResult,parseEther,formatEther,parseGwei,keccak256,getAddress,isAddress,toHex,fromHex,toBytes,fromBytes,toRlp,fromRlp,hexToBigInt,numberToHex,mnemonicToAccount,signMessage,verifyMessage.
@tevm/errors
Section titled “@tevm/errors”Umbrella subpath: tevm/errors.
Exports
Section titled “Exports”Typed BaseError hierarchy covering Ethereum RPC errors (RevertError, ExecutionError, GasLimitExceededError, InsufficientFundsError, NonceTooLowError, NonceTooHighError, InvalidParamsError, MethodNotFoundError, ParseError, InternalError, …), fork errors (ForkError, NoForkUrlSetError, NoForkTransportSetError), and parameter validation errors (InvalidAddressError, InvalidBytecodeError, InvalidAbiError, …).
@tevm/jsonrpc
Section titled “@tevm/jsonrpc”Standalone package (@tevm/jsonrpc).
Exports
Section titled “Exports”createJsonRpcFetcher(client)— wrap an EIP-1193 client in a JSON-RPC 2.0{ request }fetcher.loadBalance,rateLimit(from@ponder/utils) andhttp,webSocket(fromviem).- Types:
JsonRpcClient,JsonRpcRequest,JsonRpcResponse,JsonRpcProcedure,HeadersInit.
@tevm/viem
Section titled “@tevm/viem”Standalone package (@tevm/viem).
Exports
Section titled “Exports”tevmViemExtension()— viem client decorator addingclient.tevm.{ call, contract, deploy, deal, getAccount, setAccount, mine, dumpState, loadState }to any viem client (including remote HTTP/WebSocket clients talking to@tevm/server).
import { createPublicClient, http } from 'viem'import { tevmViemExtension } from '@tevm/viem'
const client = createPublicClient({ transport: http('http://127.0.0.1:8545'),}).extend(tevmViemExtension())
const account = await client.tevm.getAccount({ address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',})
