What is Tevm Node?
Universal JavaScript Compatibility
Tevm's key innovation is bringing the Ethereum execution environment to every JavaScript runtime:
Core Features
Network Forking
Create a local sandbox with the state of any EVM-compatible network:
import { createMemoryClient, http } from 'tevm'
import { optimism } from 'tevm/chains'
// Fork from Optimism mainnet
const client = createMemoryClient({
fork: {
transport: http('https://mainnet.optimism.io'),
common: optimism
}
})
// Access any contract or account state from the forked network
const balance = await client.getBalance({
address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' // vitalik.eth
})
Tevm's forking implementation uses:
- Lazy-loading - Only loads the state you actually access
- Efficient caching - Keeps accessed state in memory for fast subsequent access
- Latest EVM version - Supports the most recent Ethereum upgrades
Transaction Pool Management
Complete control over transaction submission and processing:
// Submit a transaction to the mempool
const hash = await client.sendTransaction({
account: '0x...',
to: '0x...',
value: 1000000000000000000n // 1 ETH
})
// View pending transactions
const pool = await client.getTxPool()
const pendingTxs = pool.getContent()
// Mine blocks to process transactions
await client.mine({ blocks: 1 })
Tevm gives you full control over:
- Transaction priority - Based on gas price, nonce, etc.
- Validation rules - Customize how transactions are validated
- Processing timing - Mine exactly when you want
Flexible Mining Control
Choose your block production model based on your needs:
// Manual mining (default)
await client.sendTransaction({ ... })
await client.mine({ blocks: 1 }) // Explicitly mine when ready
// Auto-mining
client.setMining({ mode: 'auto' }) // Mine on each transaction
// Interval mining
client.setMining({
mode: 'interval',
interval: 5000 // Mine every 5 seconds
})
Advanced Extensibility
Customize every aspect of the EVM environment:
import { createTevmNode } from 'tevm'
// Create a custom node with specialized components
const node = await createTevmNode({
evm: {
// Customize EVM execution
enableRuntimeTransform: true,
allowUnlimitedContractSize: true
},
precompiles: [
// Add custom precompiles
{
address: '0x0000000000000000000000000000000000000123',
execute: async (input, gas) => {
// Custom logic
return { executionGasUsed: 0n, returnValue: '0x123' }
}
}
]
})
Integration With Popular Libraries
Tevm works with the libraries you already know and love:
import { createMemoryClient, http } from 'tevm'
const client = createMemoryClient()
// Use standard viem actions
const balance = await client.getBalance({ address: '0x...' })
const blockNumber = await client.getBlockNumber()
// Plus Tevm-specific actions
await client.tevmMine({ blocks: 1 })
await client.tevmSetAccount({
address: '0x...',
balance: 100000000000000000n // 0.1 ETH
})
How Tevm Compares
Feature | Tevm | Anvil | Hardhat | Ganache |
---|---|---|---|---|
Language | JavaScript | Rust | JavaScript/Solidity | JavaScript |
Browser Compatible | ✅ | ❌ | ❌ | ❌ |
Zero Dependencies | ✅ | ❌ | ❌ | ❌ |
Mainnet Forking | ✅ | ✅ | ✅ | ✅ |
EVM Event Hooks | ✅ | ❌ | Partial | ❌ |
Custom Precompiles | ✅ | ✅ | ❌ | ❌ |
viem Integration | Native | Basic | Basic | Basic |
ethers Integration | Native | Basic | Basic | Basic |
Debugging | Advanced | Basic | Advanced | Basic |
TypeScript Support | Full | Limited | Full | Limited |
Serverless Compatible | ✅ | ❌ | ❌ | ❌ |
Why Choose Tevm?
🚀 Enhanced Performance
Execute transactions locally with near-zero latency for gas estimation, transaction simulation, and debugging.
💻 Browser Compatibility
Enable sophisticated dApp features like offline capabilities, optimistic UI updates, and real-time simulations.
🔍 Debug Superpowers
Step through EVM execution opcode by opcode to understand exactly what's happening in your smart contracts.
🛠️ Familiar Developer Experience
Works seamlessly with the libraries you already know - viem, ethers, or any EIP-1193 compatible tool.
Library Compatibility
Library | Support Level | Notes |
---|---|---|
viem | First-class | Native integration with all viem features |
ethers.js | Full | Both v5 and v6 via EIP-1193 provider |
web3.js | Full | Via EIP-1193 provider |
wagmi | Full | Works as a wagmi connector |
thirdweb | Full | Compatible with thirdweb's SDK |
Any EIP-1193 library | Full | Standard provider interface |