echoevm
EchoEVM is a minimal, pedagogical Ethereum Virtual Machine (EVM) implementation written in Go. It focuses on transparent bytecode execution, traceability, and ease of experimentation rather than production consensus or networking features.
๐ What's New in v0.0.14
- Nested Array Support: ABI encoding/decoding for
uint256[][],address[][], etc. - New Precompiles: Added support for MODEXP (0x05), BN256 Add/Mul/Pairing (0x06-0x08), Blake2F (0x09).
- Fork-Specific Behavior: Infrastructure to handle different hardfork rules (Merge, London active by default).
Previous v0.0.13
- Precompiled Contracts: Native support for ECRECOVER (0x01), SHA256 (0x02), RIPEMD160 (0x03), IDENTITY (0x04)
- Tuple ABI Encoding: Encode struct-like parameters using
(val1,val2,...)syntax
See ROADMAP.md for the complete version history.
โจ Features
| Category | Features |
|---|---|
| Execution | Constructor deployment, runtime calls, bytecode disassembly |
| ABI Support | Function selector encoding, primitives, arrays, bytes types |
| Tracing | JSON structured per-opcode tracing with pre/post state |
| Gas Metering | EIP-2929 compatible dynamic gas calculations |
| EIP Support | EIP-1153 (Transient Storage), EIP-5656 (MCOPY) |
| Precompiles | ECRECOVER, SHA256, RIPEMD160, IDENTITY (0x01-0x04) |
| Testing | Unit tests, integration tests, Ethereum compliance tests |
| Logging | Zerolog-based structured logging (plain/JSON output) |
โ Requirements
- Go 1.23.2+
- (Optional)
solcfor compiling.solfiles directly
๐ง Installation
From source:
Clone and build:
git clone https://github.com/smallyunet/echoevm.git
cd echoevm
make build
make install # install into GOPATH/bin
Verify:
๐ Quick Start
Run bytecode directly
# Simple arithmetic: PUSH1 1 PUSH1 2 ADD
echoevm run 6001600201
# With debug trace
echoevm run --debug 6001600201
Deploy and call a contract
# Deploy constructor bytecode
echoevm deploy -a ./artifacts/Add.json --print
# Call a function with ABI encoding
echoevm call -a ./artifacts/Add.json -f add(uint256,uint256) -A 2,40
# Generate execution trace
echoevm trace -a ./artifacts/Add.json -f add(uint256,uint256) -A 7,9 --full | jq .
Interactive REPL
๐ฅ CLI Commands
| Command | Description |
|---|---|
run |
Execute raw bytecode with optional debug tracing |
deploy |
Run constructor and extract runtime bytecode |
call |
Execute runtime bytecode with ABI encoding |
trace |
JSON line trace of opcode execution |
disasm |
Disassemble bytecode to human-readable opcodes |
repl |
Interactive EVM shell |
version |
Display build metadata |
Global Flags
--log-level, -L Log level (trace|debug|info|warn|error)
--output, -o Output format (plain|json)
--config, -c Config file path (reserved)
--rpc-url Ethereum RPC endpoint
Command Examples
deploy - Execute constructor bytecode
disasm - Disassemble bytecode
call - Execute runtime bytecode
trace - Execution trace
๐ฆ ABI Encoding
Supported types for --function/--args encoding:
| Type | Examples |
|---|---|
| Integers | uint8, uint256, int128, etc. |
| Boolean | true, false |
| Address | 0x742d35Cc... (40 hex chars) |
| String | UTF-8 dynamic strings |
| Bytes | bytes (dynamic), bytes32 (fixed) |
| Arrays | uint256[], address[] |
Array syntax:
echoevm call -a ./artifacts/Sum.json -f sum(uint256[]) -A "[1;2;3;4;5]"
echoevm call -a ./artifacts/Multi.json -f send(address[]) -A "[0xabc...;0xdef...]"
Note: Tuples and nested arrays are supported.
๐งช Testing
make test # Run all tests (unit, integration, compliance)
make test-unit # Run Go unit tests
make test-integration # Run integration tests
make test-compliance # Run Ethereum compliance tests
make setup-tests # Download test fixtures (~100MB)
๐ Architecture
echoevm/
โโโ cmd/echoevm/ # CLI commands (deploy, call, trace, etc.)
โโโ internal/
โ โโโ evm/
โ โ โโโ core/ # Stack, memory, opcode table
โ โ โโโ vm/ # Interpreter, opcode implementations
โ โโโ config/ # Constants, environment variables
โ โโโ logger/ # Zerolog wrapper
โ โโโ errors/ # Error definitions
โโโ tests/ # Integration and compliance tests
โโโ docs/ # Documentation
Supported Opcode Categories
Arithmetic, Bitwise, Comparison, Stack, Memory, Storage, Control Flow, Environment, Call/Return/Revert, Logging, System.
โ๏ธ Configuration
See Configuration and Logging Guide for details.
Environment variables:
export ECHOEVM_LOG_LEVEL=debug
export ECHOEVM_GAS_LIMIT=30000000
export ECHOEVM_ETHEREUM_RPC="https://mainnet.infura.io/v3/<key>"
๐ฆ Exit Codes
| Code | Meaning |
|---|---|
| 0 | Successful execution |
| 1 | Execution reverted (REVERT) |
| 2 | Invalid arguments / configuration error |
๐บ Roadmap
See ROADMAP.md for the complete development roadmap.
Upcoming: - Tuple and nested array ABI support - Fork-specific opcode behavior (Cancun) - Improved compliance test coverage - Web-based debugger UI
๐ค Contributing
- Fork the repository
- Create a feature branch (
feat/<topic>) - Add/update tests
- Run
make testand ensure build is clean - Open a PR with clear description
Issues and discussions for roadmap ideas are welcome!
๐ License
This project is open source under the MIT License. See LICENSE for details.
If you're using EchoEVM in research, experiments, or education, a citation or link back is appreciated.