Code Monkey home page Code Monkey logo

evmole's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.