DEV Community

Matthew
Matthew

Posted on

evm-lens: Instant, Local EVM CLI Bytecode Disassembly

“Understanding what the EVM is actually doing is the first step toward optimizing your gas usage.”

I’m thrilled to announce evm-lens v0.1.1, a lean, lightning-fast CLI and library that transforms raw EVM bytecode into a readable, color-coded opcode listing—all on your machine, in milliseconds.

Demo


🚀 TL;DR

  • v0.1.1 adds:
    • STDIN loader (--stdin) – pipe in hex from any source
    • On-chain loader (--address) – fetch code via eth_getCode
  • Works with .bin files, raw hex, or live contracts
  • Pure Rust, zero external dependencies beyond revm
  • ✅ Fully tested, CI-friendly, no SaaS lock-in
cargo install evm-lens
Enter fullscreen mode Exit fullscreen mode

🔍 The Pain Point

Smart-contract auditors, MEV researchers, and tooling engineers spend too much time:

  1. Copy-pasting hex into online disassemblers (often rate-limited or incomplete)
  2. Writing brittle scripts (curl | jq | sed) to fetch on-chain code
  3. Context-switching between terminal, browser, and local files

By the time you’ve wrangled inputs, the actual opcode analysis feels like an afterthought.


🔧 How evm-lens Helps

1. Instant, Local Disassembly

evm-lens --file MyToken.bin | less -R
Enter fullscreen mode Exit fullscreen mode

In under 10 ms, you get a line-numbered, color-coded opcode dump—no network round-trips, no web UI.

2. Flexible Input Sources

  • Direct Hex
  evm-lens 60FF61ABCD00
Enter fullscreen mode Exit fullscreen mode
  • File
  evm-lens --file path/to/Token.bin
Enter fullscreen mode Exit fullscreen mode
  • Standard Input
  echo "0x60FF61ABCD00" | evm-lens --stdin
Enter fullscreen mode Exit fullscreen mode
  • Blockchain Input
  evm-lens --address 0xAbC… --rpc https://eth.llamarpc.com
Enter fullscreen mode Exit fullscreen mode

👥 Who Should Care

  • Security Auditors & Researchers Integrate evm-lens into your CI pipeline for reliable, local bytecode snapshots.
  • Gas Optimizers Track opcode counts and static gas to measure PR impact instantly.
  • Tooling Authors Import evm-lens-core into your Rust projects and build on a battle-tested foundation.

🔮 What’s Next

Release Highlight
v0.2 --abi flag: resolve 4byte selectors & annotate CALL opcodes
v0.3 storage-diff subcommand: slot layouts, collision grading, HTML
v0.4 gas-flame: offline SVG/CSV flamegraphs for gas hot-spot analysis
v0.5 tracing: trace live blockchain transactions locally - similar to Tenderly

📥 Get Started

  1. Install or upgrade
   cargo install evm-lens
Enter fullscreen mode Exit fullscreen mode
  1. Run the CLI
   # Direct hex input
   evm-lens 60FF61ABCD00

   # From file
   evm-lens --file path/to/Token.bin

   # From stdin
   echo "0x60FF61ABCD00" | evm-lens --stdin

   # On-chain
   evm-lens --address 0xAbC… --rpc https://eth.llamarpc.com
Enter fullscreen mode Exit fullscreen mode
  1. Explore the library
   use lens_core::disassemble;
   let bytecode = hex::decode("60FF61ABCD00")?;
   let ops = disassemble(&bytecode)?;
   for (position, opcode) in ops {
       println!("{:04x}: {:?}", position, opcode);
   }
Enter fullscreen mode Exit fullscreen mode

Find the repo, file issues, and leave a star:

👉 https://github.com/andyrobert3/evm-lens


Thanks for reading! Your feedback drives this project—drop issues, PRs, or comments in Discussions. Let’s make EVM bytecode transparent and accessible to everyone.

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.