Tevm’s API is built data first. Every concept in Ethereum is given a name and a TypeScript data structure. We utilize branded types to discriminate between types that otherwise might have the same structure, such as Gwei and Ether.
Branded types and strong validators eliminate both problems.A branded type is a native JavaScript type, like Uint8Array or string, with a compile-time-only tag that prevents mixing incompatible types that would otherwise match:
Copy
Ask AI
import { Address, Bytecode } from '@tevm/voltaire';function simulateTransfer(to: Address, bytecode: Bytecode) { // Simulate contract execution}const address = Address("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e");const bytecode = Bytecode("0x60806040");// Type system catches the error!simulateTransfer(bytecode, address);// ✗ Error: Type 'Bytecode' is not assignable to parameter of type 'Address'// ✗ Error: Type 'Address' is not assignable to parameter of type 'Bytecode'
For casing issues, Tevm uses Uint8Array as the underlying type, eliminating this entire class of bugs:
Copy
Ask AI
const addr1 = Address("0x742d35cc6634c0532925a3b844bc9e7595f51e3e");const addr2 = Address("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e");// Both are same Uint8Array internallyaddr1.equals(addr2); // true
Uint8Array provides better performance (native byte operations without encoding/decoding) and follows Tevm’s philosophy of using the simplest JavaScript data structure that correctly represents the type.
Every Ethereum type is provided by Tevm. Tevm takes a data-first approach to Ethereum, thinking of Ethereum as just data that gets transformed in a stream of blocks. This allows you to focus on representing data types with strong validation, declarative transformations, and robust runtime safety.When we think of Ethereum as just basic primitive Ethereum types, those who have Ethereum domain knowledge will find using Tevm to be intuitive and easy to get in the flow state.If something has type AddressType, you know it was validated at runtime to be a valid address.
Tevm’s branded types provide critical guardrails when working with AI coding assistants like Claude Code, Cursor, or GitHub Copilot.The Problem with Structural Typing:Traditional Ethereum libraries use structural typing (type Address = \0x$“), which creates a dangerous situation for LLM-generated code:
No runtime feedback - Code compiles successfully even when semantically wrong
Context confusion - LLMs can’t differentiate between identical structural types across large codebases
Silent failures - Type system provides false confidence; bugs only surface at runtime
Tevm’s Solution:Branded types create nominal typing that LLMs can track and validate:
Copy
Ask AI
import { Address, Bytecode, Keccak256 } from '@tevm/voltaire';// LLM generates this codefunction transfer(to: Address, contract: Address) { simulateCall(contract, to); // ✓ TypeScript enforces semantic correctness}// LLM tries to pass wrong typeconst bytecode = Bytecode("0x6080");transfer(bytecode, someAddress);// ✗ Compile error: Type 'Bytecode' is not assignable to type 'Address'// ↳ LLM gets immediate feedback and self-corrects
Real-World Impact:When an LLM generates code with Tevm:
Compile-time validation catches semantic errors before execution
Type names provide context - Keccak256 is more meaningful than \0x$“
Self-documenting code - function signatures clearly communicate intent
Fewer iterations - LLM gets the types right on first attempt instead of requiring runtime debugging
This makes LLM-assisted Ethereum development significantly safer than with traditional libraries. See LLM-Optimized for how Tevm’s API design further enhances AI-assisted development.
Factory functions validate inputs at construction, eliminating the need for runtime validation libraries like Zod:
Copy
Ask AI
import { Address } from '@tevm/voltaire';// Valid inputs - all validated at constructionconst addr1 = Address("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e");const addr2 = Address(0x742d35Cc6634C0532925a3b844Bc9e7595f51e3en);
If you see a branded type, it’s validated.Any value with type AddressType has been validated to be a correct, valid address. No additional runtime checks needed.