Skip to content

Extracts function selectors from EVM bytecode, even for unverified contracts.

License

Notifications You must be signed in to change notification settings

Chaurasiasagar01/evmole

 
 

Repository files navigation

EVMole

npm PyPI license

Extracts function selectors from EVM bytecode, even for unverified contracts.

  • Python & JavaScript implementations
  • Clean code with zero dependencies
  • Faster and more accurate than other tools
  • Tested on Solidity and Vyper compiled contracts

Try it online

Usage

JavaScript

$ npm i evmole
import {functionSelectors} from 'evmole'
// Also supported: const e = require('evmole'); e.functionSelectors();

const code = '0x6080604052600436106025575f3560e01c8063b69ef8a8146029578063d0e30db014604d575b5f80fd5b3480156033575f80fd5b50603b5f5481565b60405190815260200160405180910390f35b60536055565b005b345f8082825460639190606a565b9091555050565b80820180821115608857634e487b7160e01b5f52601160045260245ffd5b9291505056fea2646970667358221220354240f63068d555e9b817619001b0dff6ea630d137edc1a640dae8e3ebb959864736f6c63430008170033'
console.log( functionSelectors(code) )
// Output(list): [ 'b69ef8a8', 'd0e30db0' ]

Python

$ pip install evmole --upgrade
from evmole import function_selectors

code = '0x6080604052600436106025575f3560e01c8063b69ef8a8146029578063d0e30db014604d575b5f80fd5b3480156033575f80fd5b50603b5f5481565b60405190815260200160405180910390f35b60536055565b005b345f8082825460639190606a565b9091555050565b80820180821115608857634e487b7160e01b5f52601160045260245ffd5b9291505056fea2646970667358221220354240f63068d555e9b817619001b0dff6ea630d137edc1a640dae8e3ebb959864736f6c63430008170033'
print( function_selectors(code) )
# Output(list): ['b69ef8a8', 'd0e30db0']

See examples for more

Benchmark

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

Dataset simple whatsabi evm-hound-rs evmole-js (py)
largest1k
1000 contracts
24427 functions
FP/FN contracts: 95 / 9 38 / 8 75 / 40 1 / 0 🥇
FP/FN functions: 749 / 12 38 / 8 🥇 🥈 720 / 191 192 / 0 🥈 🥇
Time: 1.97s 3.8s 1.34s 2.03s (1.99s)
random50k
50000 contracts
1171102 functions
FP/FN contracts: 4136 / 77 251 / 31 693 / 2903 1 / 9 🥇
FP/FN functions: 14652 / 96 261 / 32 10798 / 3538 3 / 10 🥇
Time: 35.84s 69.91s 11.97s 25.02s (33.62s)
vyper
780 contracts
21244 functions
FP/FN contracts: 185 / 480 178 / 780 19 / 300 0 / 0 🥇
FP/FN functions: 197 / 12971 181 / 21244 19 / 8273 0 / 0 🥇
Time: 1.62s 2.55s 1.29s 1.44s (1.6s)

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

How it works

Short: Executes code with a custom EVM and traces CALLDATA usage.

Long: TODO

License

MIT

About

Extracts function selectors from EVM bytecode, even for unverified contracts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 51.3%
  • JavaScript 33.7%
  • HTML 9.0%
  • Makefile 2.5%
  • Rust 2.3%
  • Dockerfile 1.2%