evmasm

Fork-aware Ethereum EVM assembler/disassembler library for MoonBit

ethereum
evm
disassembler
assembler
moonbit
moon add CAIMEOX/evmasm@0.1.0
Download zip
Author
Version
0.1.0
License
Apache-2.0
Last updated
6 months ago
Downloads
26
README

#moon_evmasm

moon_evmasm is a MoonBit Ethereum EVM assembler/disassembler library, ported from the Python project pyevmasm.

This package is library-only. It does not include a CLI layer.

#What it provides

  • Fork-aware opcode tables from frontier to osaka
  • Assemble APIs:
    • assemble_one
    • assemble_all
    • assemble
    • assemble_hex
  • Disassemble APIs:
    • disassemble_one
    • disassemble_all
    • disassemble
    • disassemble_hex
  • Fork helpers:
    • accepted_forks
    • default_fork
    • instruction_table_for_fork
    • block_to_fork
  • Structured error type: EvmError

#Quick example

// import path in this repo:
// @caimeo/moon_evmasm/src

let insn = assemble_one("PUSH1 0x10")
assert_eq(insn.mnemonic(), "PUSH1")

let bytecode_hex = assemble_hex("PUSH1 0x80\nMSTORE")
assert_eq(bytecode_hex, "0x608052")

let asm = disassemble_hex("0x60804052")
assert_eq(asm, "PUSH1 0x80\nBLOCKHASH\nMSTORE")

let fork = block_to_fork(17034870)
assert_eq(fork, "shanghai")

Error handling example:

let result = try! assemble_one("PUSH1")
assert_true(result is Err(MissingOperand(_)))

#Development

Run checks and tests from the module root:

moon -C moon_evmasm check moon -C moon_evmasm test

Current status (2026-02-09):

  • Core functionality is implemented
  • Fork tables are enum-based internally (not stringly typed)
  • Migrated test suite is passing (32 tests)

#License

Apache-2.0. See LICENSE.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io