Skip to content
LogoLogo
evmts/tevm-examples · examples.tevm.sh

Tevm examples that run against what npm actually serves.

Six standalone apps — Bun, esbuild, Vite, Next.js, SvelteKit, and MUD — each installing Tevm from the published registry with zero workspace links. Copy any of them as a starting point, or treat the repo as what it also is: Tevm's end-to-end integration smoke test.

git clone https://github.com/evmts/tevm-examples.git && cd tevm-examples && pnpm install

Pick a stack

Bun runtime with the Tevm Bun plugin: import a .sol file, fork mainnet, and read a contract with createMemoryClient.

@tevm/contract@tevm/bun-pluginviem
pnpm dlx degit evmts/tevm-examples/apps/bun my-app

esbuild bundling with the Tevm esbuild plugin and a viem public client reading from a forked memory client.

@tevm/contract@tevm/esbuild-pluginviem
pnpm dlx degit evmts/tevm-examples/apps/esbuild my-app

Vite + React + Wagmi + Ethers with a Foundry project and in-browser solc — the full frontend stack.

@tevm/contractwagmiethersviem
pnpm dlx degit evmts/tevm-examples/apps/vite my-app
apps/nextNext.js

Next.js app router running an in-browser Tevm memory client — no backend RPC required.

@tevm/contractnextviem
pnpm dlx degit evmts/tevm-examples/apps/next my-app

SvelteKit wired to Tevm through the @tevm/ethers adapter — Tevm behind a familiar ethers.js interface.

@tevm/contract@tevm/ethersethers
pnpm dlx degit evmts/tevm-examples/apps/svelte-ethers my-app

A React MUD application — onchain state synced to the client with Tevm underneath.

@latticexyz/store@tevm/contractviem
pnpm dlx degit evmts/tevm-examples/apps/mud my-app
apps/bun/readContract.ts
import { http } from '@tevm/jsonrpc'
import { ERC20 } from 'tevm/contract'
import { createMemoryClient } from 'tevm/memory-client'
 
// Fork a live chain into an in-memory EVM
const client = createMemoryClient({
	fork: { transport: http(process.env.RPC_URL ?? 'http://localhost:8545') },
})
 
// Read real chain state with full type safety — nothing to mock
const balance = await client.readContract({
	address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
	abi: ERC20.abi,
	functionName: 'balanceOf',
	args: ['0x55FE002aefF02F77364de339a1292923A15844B8'],
})
console.log(balance) // 310145594603826337866n

Published packages only

Every app installs @tevm/* from npm — no workspace links, no monorepo internals. If it runs here, it runs for you.

npm install @tevm/contract

Six toolchains

Bun, esbuild, Vite, Next.js, SvelteKit, and MUD — the same Tevm APIs working across runtimes and bundlers.

apps/{bun,esbuild,vite,next,svelte-ethers,mud}

Solidity imports everywhere

Import .sol files straight into TypeScript with fully typed contract objects via the Tevm bundler plugins.

import { Counter } from './Counter.sol'

A real smoke test

pnpm build && pnpm test in this repo is an end-to-end check that a Tevm release installs, types, bundles, and runs.

pnpm build && pnpm test

Fork mainnet locally

The examples fork Ethereum mainnet into an in-memory EVM — read real state without an archive node.

createMemoryClient({ fork: { url } })

Copy-paste starting points

Each app is a normal project. Clone the repo, or scaffold a single app with degit and start hacking.

pnpm dlx degit evmts/tevm-examples/apps/vite my-app

Tevm Examples

evmts/tevm-examples is the home of every standalone Tevm example application.

Each app in apps/ is a normal application that installs Tevm from npm — there are no workspace links back to the Tevm source tree. That single constraint is the whole point of this repository:

  • Examples that actually work. Copying a snippet out of these apps gives you code that runs against the packages npm serves you today, not against unreleased monorepo internals.
  • An integration smoke test. Because the apps resolve published versions, pnpm build && pnpm test here is a real end-to-end check that a Tevm release installs, type-checks, bundles, and runs across six different toolchains.

The applications

AppWhat it demonstrates
apps/bunBun runtime, @tevm/bun-plugin, Solidity imports, forked createMemoryClient
apps/esbuildesbuild bundling with @tevm/esbuild-plugin and a viem public client
apps/viteVite + React + Wagmi + Ethers, Foundry project, in-browser solc
apps/nextNext.js app router with an in-browser Tevm memory client
apps/svelte-ethersSvelteKit with the @tevm/ethers adapter
apps/mudA React MUD application

Start here

Where the rest of the docs live

This site documents the examples. API documentation for Tevm itself lives at tevm.sh, and the Tevm Node docs live at node.tevm.sh.

Part of the tevm.sh family

Each Tevm project has its own docs site, built on the same design system: