Expand description
Disassemble evm bytecode into individual instructions.
This crate provides a simple interface for disassembling evm bytecode into individual instructions / opcodes. It supports both hex encoded strings as well as a vector of bytes as input Additionally it provides a method to format the disassembled instructions into a human readable format identical to that of the pyevmasm library
use evm_disassembler::{disassemble_str, disassemble_bytes, format_operations};
let bytecode = "60606040526040";
let instructions = disassemble_str(bytecode).unwrap();
// Will print:
// 00000000: PUSH1 0x60
// 00000002: PUSH1 0x40
// 00000004: MSTORE
// 00000005: PUSH1 0x40
println!("{}", format_operations(instructions).unwrap());
let bytes = hex::decode(bytecode).unwrap();
let instructions_from_bytes = disassemble_bytes(bytes).unwrap();
println!("{}", format_operations(instructions_from_bytes).unwrap());
Re-exports§
Modules§
- types
- Output types for Operation and Opcode
Functions§
- disassemble_
bytes - Disassemble a vector of bytes into a vector of decoded Operations
- disassemble_
str - Disassemble a hex encoded string into a vector of instructions / operations
- format_
operations - Converts a vector of decoded operations into a human readable formatted string