Package: evmole
EVMoleThis library extractsfunction selectorsand arguments from Ethereum Virtual Machine (EVM) bytecode, even for unverified contracts.JavaScript, Rust and Python implementationsClean code with zero external dependencies (py & js)Faster and more accuratethan other existing toolsTested on Solidity and Vyper compiled contractsTry it onlineUsageJavaScript$npmievmoleimport{functionArguments,functionSelectors}from'evmole'// Also supported: const e = require('evmole'); e.functionSelectors();constcode='0x6080604052348015600e575f80fd5b50600436106030575f3560e01c80632125b65b146034578063b69ef8a8146044575b5f80fd5b6044603f3660046046565b505050565b005b5f805f606084860312156057575f80fd5b833563ffffffff811681146069575f80fd5b925060208401356001600160a01b03811681146083575f80fd5b915060408401356001600160e01b0381168114609d575f80fd5b80915050925092509256'console.log(functionSelectors(code))// Output(list): [ '2125b65b', 'b69ef8a8' ]console.log(functionArguments(code,'2125b65b'))// Output(str): 'uint32,address,uint224'RustDocumentation available ondocs.rsletcode=hex::decode("6080604052348015600e575f80fd5b50600436106030575f3560e01c80632125b65b146034578063b69ef8a8146044575b5f80fd5b6044603f3660046046565b505050565b005b5f805f606084860312156057575f80fd5b833563ffffffff811681146069575f80fd5b925060208401356001600160a01b03811681146083575f80fd5b915060408401356001600160e01b0381168114609d575f80fd5b80915050925092509256").unwrap();println!("{:x?}",evmole::function_selectors(&code,0));// Output(Vec<[u8;4]>): [[21, 25, b6, 5b], [b6, 9e, f8, a8]]println!("{}",evmole::function_arguments(&code,&[0x21,0x25,0xb6,0x5b],0));// Output(String): uint32,address,uint224Python$pipinstallevmole--upgradefromevmoleimportfunction_arguments,function_selectorscode='0x6080604052348015600e575f80fd5b50600436106030575f3560e01c80632125b65b146034578063b69ef8a8146044575b5f80fd5b6044603f3660046046565b505050565b005b5f805f606084860312156057575f80fd5b833563ffffffff811681146069575f80fd5b925060208401356001600160a01b03811681146083575f80fd5b915060408401356001600160e01b0381168114609d575f80fd5b80915050925092509256'print(function_selectors(code))# Output(list): ['2125b65b', 'b69ef8a8']print(function_arguments(code,'2125b65b'))# Output(str): 'uint32,address,uint224'FoundryFoundy's castuses the Rust implementation of EVMole$castselectors$(castcode0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)0x06fdde030x095ea7b3address,uint256
0x18160ddd0x23b872ddaddress,address,uint256
...

$castselectors--resolve$(castcode0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)0x06fdde03name()0x095ea7b3address,uint256approve(address,uint256)0x18160dddtotalSupply()0x23b872ddaddress,address,uint256transferFrom(address,address,uint256)...Seeexamplesfor moreBenchmarkfunction selectorsFP/FN-False Positive/False Negativeerrors;smaller is betterDatasetevmolers·js·pywhatsabievm-hound-rsheimdall-rssimplelargest1k1000contracts24427functionsFPcontracts1 🥈0 🥇751895FNcontracts0 🥇8401029FPfunctions192 🥈0 🥇720600749FNfunctions0 🥇8 🥈19111312Time0.7s · 1.5s · 2.0s3.0s0.7s727.2s1.9srandom50k50000contracts1171102functionsFPcontracts1 🥇43693waiting fixes4136FNcontracts9 🥇31290377FPfunctions3 🥇511079814652FNfunctions10 🥇32353896Time9.8s · 19.6s · 36.4s52.3s11.5s46.3svyper780contracts21244functionsFPcontracts0 🥇30190185FNcontracts0 🥇780300780480FPfunctions0 🥇30190197FNfunctions0 🥇2124482732124412971Time0.6s · 0.9s · 1.4s2.3s0.6s17.0s1.2sfunction argumentsErrors- when at least 1 argument is incorrect:(uint256,string)!=(uint256,bytes);smaller is betterDatasetevmolers·js·pyheimdall-rssimplelargest1k1000contracts24427functionsErrors15.0%, 3652 🥇42.7%, 1043858.3%, 14242Time1.1s · 7.5s · 15.7s731.4s0.8srandom50k50000contracts1171102functionsErrors5.1%, 59484 🥇waiting fixes54.9%, 643213Time22.6s · 247.0s · 584.7s9.5svyper780contracts21244functionsErrors50.9%, 10805 🥇100.0%, 2124456.8%, 12077Time0.9s · 7.3s · 13.9s16.8s0.7sSeebenchmark/README.mdfor the methodology and commands to reproduce these resultsversions: evmole v0.3.3; whatsabi v0.11.0; evm-hound-rs v0.1.4; heimdall-rs v0.7.3How it worksShort: Executes code with a custom EVM and traces CALLDATA usage.Long: TODOLicenseMIT