gakonst / ethers-rs

Complete Ethereum & Celo library and wallet implementation in Rust. https://docs.rs/ethers
Apache License 2.0
2.5k stars 796 forks source link

Add dedicated etherscan client #485

Open mattsse opened 3 years ago

mattsse commented 3 years ago

Tracking issue for complete ethers-etherscan client crate

Endpoints

Overview https://docs.etherscan.io/api-endpoints/

Initial WIP https://github.com/gakonst/dapptools-rs/pull/82 #486

with the Query type, etherscan api requests can be easily created like

let mut map = HashMap::new();
map.insert("address", address);
// this will create the `query` object that gets serialized into the final url like:
// https://api.etherscan.io/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken
let query = self.create_query("contract", "getabi", map);
let resp: Response<String> = self.get_json(&query).await?;

Some endpoints will require quite a bit of parameters, for these cases (>3 params) a config struct with Serialize should be created, (check https://github.com/gakonst/ethers-rs/blob/master/ethers-etherscan/src/lib.rs#L201-L229)

/// Arguments for verifying contracts
#[derive(Debug, Clone, Serialize)]
pub struct EndpointParams {
    pub address: Address,
   // --snip--
}

Other todos

gakonst commented 3 years ago

Transactions were implemented in #512. @brockelmore if you end up looking at dapp create (https://github.com/gakonst/dapptools-rs/issues/43) you may want to take a look at the verification issue @mattsse mentions above.