@tevm/memory-client
Version:
MemoryClient for tevm is an in memory devnet for JavaScript
57 lines • 3.31 kB
TypeScript
export function createTevmTransport(options?: import("@tevm/node").TevmNodeOptions): import("./TevmTransport.js").TevmTransport;
/**
* Creates a custom TEVM Transport for viem clients, integrating an in-memory Ethereum Virtual Machine.
*
* A Transport in viem is the intermediary layer responsible for executing outgoing JSON-RPC requests.
* The TEVM Transport implementation replaces network requests with direct calls to an in-memory EVM,
* providing several key advantages:
*
* - **Local-first operation**: All EVM execution happens directly in the JavaScript runtime
* - **Zero network latency**: No round-trips to remote nodes for operations
* - **Deterministic execution**: Full control over the execution environment for testing
* - **Advanced tracing**: Step-by-step EVM execution with introspection capabilities
* - **Forking capabilities**: Can lazily load state from remote networks as needed
* - **Customizable state**: Direct manipulation of accounts, balances, storage, and more
*
* The transport can be used with any viem client (wallet, public, or test) and fully supports the
* EIP-1193 provider interface, making it compatible with the broader Ethereum ecosystem.
*/
export type TevmTransportConfig = {
/**
* - Timeout duration for requests in milliseconds. Default is 20,000 ms. Supplied by viem.
*/
timeout?: number;
/**
* - The maximum number of times to retry a failed request. Default is 3. Supplied by viem.
*/
retryCount?: number;
/**
* - Blockchain configuration. Defaults to the chain specified in `options` or the default TEVM chain.
*
* ## Key Transport Options
*
* - `timeout` (optional, number): Timeout duration for requests in milliseconds. Default is 20,000 ms.
* - `retryCount` (optional, number): The maximum number of times to retry a failed request. Default is 3.
* - `chain` (optional, Chain): Blockchain configuration. Defaults to the chain in `options` or TEVM default.
*
* ## Key Node Options
*
* - `fork` (optional): Configuration for forking from an existing network
* - `transport`: An EIP-1193 compatible transport (e.g., from viem's http function)
* - `blockTag` (optional): Block number/hash to fork from (defaults to 'latest')
* - `mining` (optional): Mining configuration
* - `auto` (boolean): Whether to automatically mine after transactions
* - `interval` (number): Milliseconds between automatic block mining (0 = disabled)
* - `common` (optional): Chain configuration (recommended for optimal performance)
* - `persister` (optional): For state persistence between sessions
*
* ## Gotchas and Best Practices
*
* - When specifying a chain, use TEVM common instead of viem chains. You can create a TEVM common from a viem chain using `createCommon`.
* - The transport creates an internal cache of TEVM nodes keyed by chain ID, so multiple clients with the same chain ID share state.
* - For full control over a client's state, either use unique chain IDs or the higher-level `createMemoryClient`.
* - Access the underlying TEVM node via `client.transport.tevm` for advanced operations.
*/
chain?: import("viem").Chain;
};
//# sourceMappingURL=createTevmTransport.d.ts.map