cargo new abi_decode
# edit Cargo.toml and src/main.rs with the files aboe
# create src/abi/<abi>.abi with the abi to decode
cargo run
Last active
January 29, 2022 15:01
-
-
Save Lucas-Kohorst/fcbcc1515e0b5978d11b7fb5bed317d6 to your computer and use it in GitHub Desktop.
Function Signatures from ABI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "method_decode" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
dotenv = "0.15.0" | |
ethabi = "15.0.0" | |
hex = "0.4.3" | |
rustc-hex = "2.1.0" | |
primitive-types = "0.6.1" | |
serde_json = "1.0.64" | |
[dependencies.serde] | |
features = ["derive"] | |
version = "1.0.124" | |
[dependencies.url] | |
default-features = false | |
version = "2.2.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{fs, str::FromStr, sync::Arc}; | |
use ethabi::Error; | |
fn main() { | |
let router = ethabi::Contract::load(fs::read("src/abi/abi.abi").unwrap().as_slice()).unwrap(); | |
let iter = router.functions().into_iter(); | |
for f in iter { | |
let method_id = hex::encode(f.short_signature()); | |
println!("Function Method ID: {:?} \n\t{:?}", method_id, f); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment