EVMole
EVMole is a powerful library that extracts information from Ethereum Virtual Machine (EVM) bytecode, including function selectors, arguments, and state mutability, even for unverified contracts.
Key Features
- Multi-language support: Available as JavaScript, Rust, and Python libraries.
- High accurancy and performance: Outperforms existing tools.
- Broad compatibility: Tested with both Solidity and Vyper compiled contracts.
- Lightweight: Clean codebase with minimal external dependencies.
- Unverified contract analysis: Extracts information even from unverified bytecode.
Usage
JavaScript
API documentation and usage examples (node, vite, webpack, parcel, esbuild)
import from 'evmole'
const code = '0x6080604052348015600e575f80fd5b50600436106030575f3560e01c80632125b65b146034578063b69ef8a8146044575b5f80fd5b6044603f3660046046565b505050565b005b5f805f606084860312156057575f80fd5b833563ffffffff811681146069575f80fd5b925060208401356001600160a01b03811681146083575f80fd5b915060408401356001600160e01b0381168114609d575f80fd5b80915050925092509256'
console.log; // [ '2125b65b', 'b69ef8a8' ]
console.log; // 'uint32,address,uint224'
console.log; // 'pure'
Rust
Documentation is available on docs.rs
let code = decode.unwrap;
println!;
// [[21, 25, b6, 5b], [b6, 9e, f8, a8]] | uint32,address,uint224 | Pure
Python
=
# ['2125b65b', 'b69ef8a8']
# uint32,address,uint224
# pure
Foundry
Foundy's cast uses the Rust implementation of EVMole
)
)
)
)
Benchmark
function selectors
FP/FN - False Positive/False Negative errors; smaller is better
function arguments
Errors - when at least 1 argument is incorrect: (uint256,string) ≠ (uint256,bytes)
function state mutability
Errors - Results are not equal (treating view and pure as equivalent to nonpayable)
Errors strict - Results are strictly unequal (nonpayable ≠ view). Some ABIs mark pure/view functions as nonpayable, so not all strict errors indicate real issues.
See benchmark/README.md for the methodology and commands to reproduce these results
versions: evmole v0.5.1; whatsabi v0.14.1; sevm v0.7.2; evm-hound-rs v0.1.4; heimdall-rs v0.8.4
(*): sevm and heimdall-rs are full decompilers, not limited to extracting function selectors
How it works
Short: Executes code with a custom EVM and traces CALLDATA usage.
Long: TODO
License
MIT