Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Bundler Quickstart

Tevm bundler plugins compile .sol imports at build time and generate modules containing ABI, bytecode, and type-safe contract helpers.

Install

npm install tevm@1.0.0-rc.151 viem

The tevm package exposes plugin entry points for Vite, Rollup, esbuild, Webpack, rspack, and Bun.

Vite

import { defineConfig } from 'vite'
import { vitePluginTevm } from 'tevm/bundler/vite-plugin'
 
export default defineConfig({
  plugins: [vitePluginTevm()],
})

Rollup

import { rollupPluginTevm } from 'tevm/bundler/rollup-plugin'
 
export default {
  input: 'src/index.ts',
  plugins: [rollupPluginTevm()],
}

esbuild

import { build } from 'esbuild'
import { esbuildPluginTevm } from 'tevm/bundler/esbuild-plugin'
 
await build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  outfile: 'dist/index.js',
  plugins: [esbuildPluginTevm()],
})

Webpack

import { WebpackPluginTevm } from 'tevm/bundler/webpack-plugin'
 
export default {
  plugins: [new WebpackPluginTevm()],
}

The Webpack export is the WebpackPluginTevm constructor with an uppercase W.

Import a Contract

Given:

// src/Counter.sol
pragma solidity ^0.8.20;
 
contract Counter {
    uint256 public number;
    function setNumber(uint256 next) public { number = next; }
}

Import the generated contract module:

import { Counter } from './Counter.sol'
import { createMemoryClient } from 'tevm'
 
const client = createMemoryClient()
const counter = Counter.withAddress(
  '0x2222222222222222222222222222222222222222',
)
 
await client.setCode({
  address: counter.address,
  bytecode: counter.deployedBytecode,
})
 
const number = await client.readContract(counter.read.number())
console.log(number)

.s.sol script contracts include creation bytecode. Plain .sol imports always provide ABI helpers and provide bytecode when the compiler output includes it.

Supported rc.151 Surface

The rc.151 bundler supports filesystem Solidity imports and the package plugin entry points above. It does not export the proposed sol template tag or loadContract/CAIP-10 contract loader APIs.

Related

Bundler Overview · Plugin Reference · Troubleshooting