evm_hound

Crates.ioevm_hound
lib.rsevm_hound
version0.1.4
sourcesrc
created_at2023-11-14 14:46:57.749279
updated_at2023-11-22 19:29:56.90757
descriptionA Minimalistic Rust library to extract all potential function selectors from EVM bytecode without source code
homepage
repositoryhttps://github.com/g00dv1n/evm-hound-rs
max_upload_size
id1034868
size130,369
(g00dv1n)

documentation

https://docs.rs/evm_hound

README

EVM Hound

A Minimalistic Rust library to extract all potential function selectors from EVM bytecode without source code.

Installation

$ cargo add evm_hound

Usage

// examples/basic.rs
use ethers::{
    providers::{Http, Middleware, Provider},
    types::Address,
};
use eyre::Result;

use evm_hound::{selectors_from_bytecode, string_selectors_from_bytecode};

// To Try:
// cargo run --example basic

#[tokio::main]
async fn main() -> Result<()> {
    let provider = Provider::<Http>::try_from("https://rpc.flashbots.net/fast")?;
    let token_addr: Address = "0xdac17f958d2ee523a2206206994597c13d831ec7".parse()?;

    let code = provider.get_code(token_addr, None).await?;

    let raw_selectors = selectors_from_bytecode(&code);
    let string_selectors = string_selectors_from_bytecode(&code);

    println!("found {} selectors", raw_selectors.len());
    println!("{raw_selectors:?}");
    println!("{string_selectors:?}");

    Ok(())
}

Also, EVM Hound can detect basic contract types using extracted selectors:

pub enum ContractType {
    /// ERC20 - Typical token contract
    ERC20,
    /// ERC721 - Typical NFT contract
    ERC721,
    /// Any other contract
    ANY,
}

Check out example at examples/contract_type.rs.

Credits

Made for Hackers.tools Trading Simulator to search/bruteforce for potential methods that start trading.

Commit count: 18

cargo fmt