Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toy-evm

A minimal Ethereum Virtual Machine implementation in Rust.

Features

  • Stack: 1024-depth LIFO with overflow/underflow detection
  • Memory: Byte-addressable storage with word operations
  • Storage: Persistent state organized by contract address
  • Opcodes: Arithmetic, bitwise, comparison, control flow, memory, storage operations
  • Execution: Jump table dispatch for bytecode interpretation

Supported Opcodes

Category Opcodes
Arithmetic ADD, SUB, MUL, DIV, MOD, EXP, ADDMOD, MULMOD
Comparison LT, GT, SLT, SGT, EQ, ISZERO
Bitwise AND, OR, XOR, NOT, SHL, SHR, SAR, BYTE
Stack PUSH0-PUSH32, DUP1-DUP16, SWAP1-SWAP16, POP
Memory MLOAD, MSTORE, MSTORE8
Storage SLOAD, SSTORE
Control STOP, JUMP, JUMPI, JUMPDEST, PC
System CREATE, CALL, DELEGATECALL, STATICCALL, RETURN, REVERT

Usage

cargo run

Architecture

crates/
├── primitives/   # Core types: Stack, Memory, Storage, Transaction, Account
└── evm_core/     # Execution engine, opcodes, jump table
bins/
└── evm/          # Example runner with contract bytecode

License

MIT

TOY_EVM

About

A minimal Ethereum Virtual Machine implementation in Rust

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages