8000 GitHub - chimera-defi/evmole: Extracts function selectors from EVM bytecode, even for unverified contracts.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
forked from cdump/evmole

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

License

Notifications You must be signed in to change notification settings

chimera-defi/evmole

 
 

Repository files navigation

EVMole

PyPI npm 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 evmole-js (py)
largest1k
1000 contracts
24427 functions
FP/FN contracts: 95 / 9 38 / 8 1 / 0 🥇
FP/FN functions: 749 / 12 38 / 8 🥇 🥈 192 / 0 🥈 🥇
Time: 2.06s 3.8s 1.99s (2.09s) 🚀
random50k
50000 contracts
1171102 functions
FP/FN contracts: 4136 / 77 251 / 31 1 / 9 🥇
FP/FN functions: 14652 / 96 261 / 32 3 / 10 🥇
Time: 32.3s 71.13s 25.63s (33.56s) 🚀
vyper
780 contracts
21244 functions
FP/FN contracts: 185 / 480 178 / 780 0 / 0 🥇
FP/FN functions: 197 / 12971 181 / 21244 0 / 0 🥇
Time: 1.71s 2.52s 1.58s (1.8s) 🚀

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 48.1%
  • JavaScript 40.6%
  • HTML 8.1%
  • Makefile 2.3%
  • Dockerfile 0.9%
0