Skip to content

owanesh/evm2wasm

 
 

Repository files navigation

evm2wasm

Minimal EVM bytecode to WebAssembly compiler.

Tip

As stated in the original code, see RuneVM and yevm for replacement candidates.

Install

npm install

The CLI validates every .wasm file it writes with wasm-validate, so WABT must be installed and available:

sudo apt install wabt

CLI

Produce WASM

bin/evm2wasm.js 6000 -o out.wasm
bin/evm2wasm.js bytecode.hex -o out.wasm
bin/evm2wasm.js bytecode.bin -o out.wasm

Every .wasm file left on disk has passed wasm-validate. If validation fails, the CLI deletes the generated .wasm and exits with an error.

To convert from hexadecimal to .bin, this one-liner can be useful:

tr -d '[:space:]' < example.hex | xxd -r -ps > example.bin

Produce WASM and WAT

bin/evm2wasm.js bytecode.hex -o out.wasm --wat
bin/evm2wasm.js bytecode.hex -o out.wasm --wat myOut.wat

When --wat is passed without a file, the text output is derived from -o; for example out.wasm writes out.wat.

When producing WAT together with WASM, the WAT file is written only after the .wasm output has passed wasm-validate; failed WASM outputs are discarded.

Produce WASM and WAST

bin/evm2wasm.js bytecode.hex -o out.wasm --wast myOut.wast

API

const evm2wasm = require('./index.js')

const wasm = await evm2wasm.evm2wasm(Buffer.from('6000', 'hex'))
const wat = evm2wasm.evm2wat(Buffer.from('6000', 'hex'))
const wast = evm2wasm.evm2wast(Buffer.from('6000', 'hex'))

License

As in the original code, this patch is redistributed under the MPL-2.0 license.

Caution

This repository is no longer maintained. The fork exists solely to enable compatibility with newer versions of wabt in 2026. Use this fork only if you need evm2wasm to work with the latest wabt releases; no further updates or support are planned.

About

[ORPHANED] Transcompiles EVM code to eWASM

Resources

License

Stars

Watchers

Forks

Contributors

Languages

  • C++ 63.3%
  • WebAssembly 23.1%
  • JavaScript 10.0%
  • CMake 3.5%
  • Other 0.1%