Skip to content


BaseClientOptions: StateOptions & object

Options for creating an Tevm MemoryClient instance

Type declaration


optional readonly allowUnlimitedContractSize: boolean

Enable/disable unlimited contract size. Defaults to false.


optional readonly chainId: number

Optionally set the chainId. Defaults to chainId of fokred/proxied chain or 900


optional readonly customPrecompiles: CustomPrecompile[]

Custom precompiles allow you to run arbitrary JavaScript code in the EVM. See the Precompile guide documentation for a deeper dive An ever growing standard library of precompiles is provided at tevm/precompiles


Not implemented yet Implementation pr

Below example shows how to make a precompile so you can call fs.writeFile and fs.readFile in your contracts. Note: this specific precompile is also provided in the standard library

For security precompiles can only be added statically when the vm is created.


import { createMemoryClient, defineCall, definePrecompile } from 'tevm'
import { createScript } from '@tevm/contract'
import fs from 'fs/promises'
const Fs = createScript({
name: 'Fs',
humanReadableAbi: [
'function readFile(string path) returns (string)',
'function writeFile(string path, string data) returns (bool)',
const fsPrecompile = definePrecompile({
contract: Fs,
address: '0xf2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2',
call: defineCall(Fs.abi, {
readFile: async ({ args }) => {
return {
returnValue: await fs.readFile(...args, 'utf8'),
executionGasUsed: 0n,
writeFile: async ({ args }) => {
await fs.writeFile(...args)
return { returnValue: true, executionGasUsed: 0n }
const tevm = createMemoryClient({ customPrecompiles: [fsPrecompile] })
### customPredeploys?
> `optional` `readonly` **customPredeploys**: `ReadonlyArray`\<[`CustomPredeploy`](/reference/tevm/predeploys/type-aliases/custompredeploy/)\<`any`, `any`\>\>
Custom predeploys allow you to deploy arbitrary EVM bytecode to an address.
This is a convenience method and equivalent to calling tevm.setAccount() manually
to set the contract code.
const tevm = createMemoryClient({
customPredeploys: [
// can pass a `tevm Script` here as well
address: '0x420420...',
abi: [...],
deployedBytecode: '0x420420...',


optional readonly eips: ReadonlyArray<number>

Eips to enable. Defaults to [1559, 4895]


optional readonly hardfork: Hardfork

Hardfork to use. Defaults to shanghai


optional readonly loggingLevel: LogOptions["level"]

Configure logging options for the client


optional readonly miningConfig: MiningConfig

The configuration for mining. Defaults to ‘auto'

  • 'auto’ will mine a block on every transaction
  • ’interval’ will mine a block every interval milliseconds
  • ’manual’ will not mine a block automatically and requires a manual call to mineBlock


optional readonly persister: SyncStoragePersister

The memory client can optionally initialize and persist it’s state to an external source like local storage using createSyncPersister


import { createMemoryClient, createSyncPersister } from 'tevm'
const persister = createSyncPersister({
storage: {
getItem: (key: string) => localStorage.getItem(key),
setItem: (key: string, value: string) => localStorage.setItem(key, value),
const memoryClient = createMemoryClient({ persister })


optional readonly profiler: boolean

Enable profiler. Defaults to false.