Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

evmole

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

evmole

Extracts function selectors and arguments from EVM bytecode

  • 0.6.2
  • PyPI
  • Socket score

Maintainers
1

EVMole

try it online npm Crates.io PyPI

EVMole is a powerful library that extracts information from Ethereum Virtual Machine (EVM) bytecode, including function selectors, arguments, state mutability, and storage layout, even for unverified contracts.

Key Features

  • Multi-language support: Available as JavaScript, Rust, and Python libraries.
  • High accuracy 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)

$ npm i evmole
import { contractInfo } from 'evmole'

const code = '0x6080604052348015600e575f80fd5b50600436106030575f3560e01c80632125b65b146034578063b69ef8a8146044575b5f80fd5b6044603f3660046046565b505050565b005b5f805f606084860312156057575f80fd5b833563ffffffff811681146069575f80fd5b925060208401356001600160a01b03811681146083575f80fd5b915060408401356001600160e01b0381168114609d575f80fd5b80915050925092509256'

console.log( contractInfo(code, {selectors:true, arguments:true, stateMutability:true}) )
// {
//   functions: [
//     {
//       selector: '2125b65b',
//       bytecodeOffset: 52,
//       arguments: 'uint32,address,uint224',
//       stateMutability: 'pure'
//     },
//     ...

Rust

Documentation is available on docs.rs

let code = hex::decode("6080604052348015600e575f80fd5b50600436106030575f3560e01c80632125b65b146034578063b69ef8a8146044575b5f80fd5b6044603f3660046046565b505050565b005b5f805f606084860312156057575f80fd5b833563ffffffff811681146069575f80fd5b925060208401356001600160a01b03811681146083575f80fd5b915060408401356001600160e01b0381168114609d575f80fd5b80915050925092509256").unwrap();

println!("{:?}", evmole::contract_info(
    evmole::ContractInfoArgs::new(&code)
        .with_selectors()
        .with_arguments()
        .with_state_mutability()
    )
);
// Contract {
//     functions: Some([
//         Function {
//             selector: [33, 37, 182, 91],
//             bytecode_offset: 52,
//             arguments: Some([Uint(32), Address, Uint(224)]),
//             state_mutability: Some(Pure)
//         },
//         ...

Python

API documentation

$ pip install evmole --upgrade
from evmole import contract_info

code = '0x6080604052348015600e575f80fd5b50600436106030575f3560e01c80632125b65b146034578063b69ef8a8146044575b5f80fd5b6044603f3660046046565b505050565b005b5f805f606084860312156057575f80fd5b833563ffffffff811681146069575f80fd5b925060208401356001600160a01b03811681146083575f80fd5b915060408401356001600160e01b0381168114609d575f80fd5b80915050925092509256'

print( contract_info(code, selectors=True, arguments=True, state_mutability=True) )
# Contract(
#     functions=[
#     Function(
#             selector=2125b65b,
#             bytecode_offset=52,
#             arguments=uint32,address,uint224,
#             state_mutability=pure),
#     ...

Foundry

Foundy's cast uses the Rust implementation of EVMole


$ cast selectors $(cast code 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)
0x06fdde03                           view
0x095ea7b3  address,uint256          nonpayable
0x18160ddd                           view
0x23b872dd  address,address,uint256  nonpayable
...

$ cast selectors --resolve $(cast code 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)
0x06fdde03                           view        name()
0x095ea7b3  address,uint256          nonpayable  approve(address,uint256)
0x18160ddd                           view        totalSupply()
0x23b872dd  address,address,uint256  nonpayable  transferFrom(address,address,uint256)
...

Benchmark

function selectors

FP/FN - False Positive/False Negative errors; smaller is better

Datasetevmole rs · js · pywhatsabisevmevmhoundheimdallsmpl
largest1k
1000
addresses

24427
functions
FP addrs1 🥈0 🥇0 🥇751895
FN addrs0 🥇0 🥇0 🥇401119
FP funcs192 🥈0 🥇0 🥇720600749
FN funcs0 🥇0 🥇0 🥇19114712
Time0.4s · 0.6s · 0.4s2.8s35s(*)0.4s343s(*)1.6s
random50k
50000
addresses

1171102
functions
FP addrs1 🥇43169334136
FN addrs9 🥇11102903470877
FP funcs3 🥇513107982914652
FN funcs10 🥇12113538609896
Time4.3s · 9.0s · 7.2s53s1124s(*)5.8s8572s(*)44s
vyper
780
addresses

21244
functions
FP addrs0 🥇300190185
FN addrs0 🥇7800300780480
FP funcs0 🥇300190197
FN funcs0 🥇21244082732124412971
Time0.3s · 0.6s · 0.4s2.0s46s(*)0.3s28s(*)1.0s

function arguments

Errors - when at least 1 argument is incorrect: (uint256,string)(uint256,bytes)

Datasetevmole rs · js · pyheimdallsmpl
largest1k
24427
functions
Errors14.0% 🥇
3410
31.1%
7593
58.3%
14242
Time1.0s · 2.1s · 1.1s344s(*)0.5s
random50k
1171102
functions
Errors4.5% 🥇
52670
19.4%
227612
54.9%
643213
Time20s · 49s · 24s8517s(*)8.1s
vyper
21244
functions
Errors48.5% 🥇
10299
100.0%
21244
56.8%
12077
Time0.7s · 1.4s · 0.8s28s(*)0.5s

function state mutability

Errors - Results are not equal (treating view and pure as equivalent to nonpayable)

Errors strict - Results are strictly unequal (nonpayableview). Some ABIs mark pure/view functions as nonpayable, so not all strict errors indicate real issues.

Datasetevmole rs · js · pywhatsabisevmheimdallsmpl
largest1k
24427
functions
Errors0.0% 🥇
0
68.1%
16623
2.1%
501
25.4%
6201
2.6%
643
Errors strict18.6% 🥇
4555
79.4%
19393
59.0%
14417
54.9%
13403
60.9%
14864
Time8.9s · 16s · 8.9s3.8s33s(*)339s(*)0.5s
random50k
1160861
functions
Errors0.0% 🥇
44
30.2%
351060
0.3%
3370
11.6%
134196
2.2%
24961
Errors strict6.8% 🥇
78923
58.2%
675111
55.7%
646831
27.7%
321495
57.7%
670318
Time169s · 334s · 172s88s1131s(*)8267s(*)8.2s
vyper
21166
functions
Errors0.5% 🥇
110
100.0%
21166
76.3%
16150
100.0%
21166
1.8%
390
Errors strict4.0% 🥇
854
100.0%
21166
90.2%
19092
100.0%
21166
59.6%
12610
Time9.5s · 13s · 9.7s2.1s38s(*)28s(*)0.5s

See benchmark/README.md for the methodology and commands to reproduce these results

versions: evmole v0.6.2; whatsabi v0.17.0; sevm v0.7.3; 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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc