Expand description
The evmasm crate aims to provide a simple interface for the conversion between evm bytecode and it’s human readable form.
extern crate evmasm;
use evmasm::{assemble, disassemble};
fn main() {
let bytecode = assemble("PUSH1 2 PUSH1 1 ADD").unwrap();
println!("{:?}", bytecode);
let code = disassemble(&bytecode).unwrap();
for ln in code {
println!("{}", ln);
}
}
extern crate evmasm;
use evmasm::{BYTE_INST, instruction, arguments_size};
fn main() {
for (&bc, _) in BYTE_INST.iter() {
let inst = instruction(bc).ok().unwrap();
println!("0x{:2x} - {} - needs {} bytes of arguments",
bc,
inst,
arguments_size(bc).ok().unwrap());
}
}
Re-exports§
Structs§
- BYTE_
INST - Lazily initialized struct that derefs into an HashMap<u8, &'static str>
- INST_
BYTE - Lazily initialized struct that derefs into an HashMap<&'static str, u8>
Enums§
- Error
- Error is only returned when an instruction/bytecode is not found
Functions§
- arguments_
size - Return the size in bytes of the arguments of a specific bytecode
- assemble
- bytecode
- Return the bytecode corresponding to the provided instruction
- disassemble
- instruction
- Return the instruction corresponding to the provided bytecode