Skip to content

createTevmTransport

createTevmTransport(options): TevmTransport<string>

Creates a custom TEVM Transport for viem.

A Transport in viem is the intermediary layer responsible for executing outgoing RPC requests. This custom TEVM Transport integrates an in-memory Ethereum client, making it ideal for local-first applications, optimistic updates, and advanced TEVM functionalities like scripting.

Parameters

options: TevmNodeOptions<object> = {}

Configuration options for the base client, similar to those used in memoryClient or a low-level baseClient.

Returns

TevmTransport<string>

A configured TEVM transport.

Example

import { createClient, http } from 'viem'
import { createTevmTransport } from 'tevm'
import { optimism } from 'tevm/common'
const client = createClient({
transport: createTevmTransport({
fork: { transport: http('https://mainnet.optimism.io')({}) }
}),
chain: optimism,
})
async function example() {
const blockNumber = await client.getBlockNumber()
console.log(blockNumber)
}
example()

See

Defined in

packages/memory-client/src/createTevmTransport.js:58