Minimal EVM bytecode to WebAssembly compiler.
Tip
As stated in the original code, see RuneVM and yevm for replacement candidates.
npm installThe CLI validates every .wasm file it writes with wasm-validate, so WABT must be installed and available:
sudo apt install wabtbin/evm2wasm.js 6000 -o out.wasm
bin/evm2wasm.js bytecode.hex -o out.wasm
bin/evm2wasm.js bytecode.bin -o out.wasmEvery .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.binbin/evm2wasm.js bytecode.hex -o out.wasm --wat
bin/evm2wasm.js bytecode.hex -o out.wasm --wat myOut.watWhen --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.
bin/evm2wasm.js bytecode.hex -o out.wasm --wast myOut.wastconst 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'))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.