Skip to content

MilosMicun/evm-simulator-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniEVM Simulator (JavaScript)

A simple Ethereum Virtual Machine (EVM) simulator built in JavaScript.
This project helps you understand how the EVM executes opcodes, manages stack, memory, storage, and control flow.

Features

  • Stack operations: PUSH, POP, DUP, SWAP
  • Arithmetic: ADD, SUB, MUL, DIV
  • Memory operations: MSTORE, MLOAD
  • Storage operations: SSTORE, SLOAD
  • Control flow: JUMP, JUMPI
  • Logic operations: EQ, LT, GT, ISZERO

Project Structure

mini-evm/ ├─ src/ │ ├─ evm.js # MiniEVM implementation │ └─ programs.js # Test programs ├─ index.js # Test runner ├─ package.json └─ README.md

bash Copy code

Usage

  1. Install Node.js if not already installed.
  2. Clone the repository:
git clone https://github.com/MilosMicun/evm-simulator-js.git
cd evm-simulator-js
Run all tests:

bash
Copy code
node index.js
You should see output for all test cases showing the final stack, memory, and storage.

Example Output
yaml
Copy code
===== Running: Simple Addition Test =====
Final stack: [ 5 ]
Memory: {}
Storage: {}
Future Work
Add more EVM opcodes

Simulate gas consumption

Extend for Solidity-like function calls

Author
Milos Micun – learning blockchain & EVM internals with JavaScript

About

A minimal EVM simulator in JavaScript implementing stack, memory, storage and opcode execution to explore Ethereum Virtual Machine internals at the instruction level.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors