Crates.io | evm_hound |
lib.rs | evm_hound |
version | 0.1.4 |
source | src |
created_at | 2023-11-14 14:46:57.749279 |
updated_at | 2023-11-22 19:29:56.90757 |
description | A Minimalistic Rust library to extract all potential function selectors from EVM bytecode without source code |
homepage | |
repository | https://github.com/g00dv1n/evm-hound-rs |
max_upload_size | |
id | 1034868 |
size | 130,369 |
A Minimalistic Rust library to extract all potential function selectors from EVM bytecode without source code.
$ cargo add evm_hound
// 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.
Made for Hackers.tools Trading Simulator to search/bruteforce for potential methods that start trading.