#machine #virtual-machine #tiny #pure #ethereum #opcode #u256

bin+lib xevm

Tiny Ethereum virtual machine written in pure Rust

4 releases

0.1.3 Jan 7, 2025
0.1.2 Jan 7, 2025
0.1.1 Jan 7, 2025
0.1.0 Jan 7, 2025

#8 in #u256

Download history 224/week @ 2025-01-07 4/week @ 2025-01-14

228 downloads per month

MIT license

100KB
2.5K SLoC

xevm

Tests badge

xevm is a tiny implementation of Ethereum Virtual Machine, written in pure Rust!

Sample usage:

use alloy_primitives::primitives::{Address, U256};
use xevm::context::MiniEthereum;
use xevm::machine::{CallInfo, Machine};
use xevm::opcodes::ExecutionResult;

fn main() {
    let code = vec![];
    let mut ctx = MiniEthereum::new();
    let exec_result = Machine::new(Address::ZERO, code.clone())
        .run(
            &mut ctx,
            &CallInfo {
                origin: Address::ZERO,
                caller: Address::ZERO,
                call_value: U256::ZERO,
                calldata: vec![0xd0, 0x9d, 0xe0, 0x8a],
            },
        )
        .unwrap();
    match exec_result {
        ExecutionResult::Returned(ret) => {
            println!("Returned {:?}!", ret);
        }
        ExecutionResult::Halted => {
            println!("Halted!");
        }
    }
}

Dependencies

~10MB
~175K SLoC