Git Product home page Git Product logo

block-explorers's Introduction

foundry-block-explorers

Crates for interacting with explorer APIS.

Build Status Telegram chat

Overview

This repository contains the following crates:

  • [foundry-block-explorers]: Bindings for etherscan.io API.
  • [foundry-blob-explorers]: Bindings for blobscan.com API.

Supported Rust Versions

We will keep a rolling MSRV (minimum supported rust version) policy of at least 6 months. When increasing the MSRV, the new Rust version must have been released at least six months ago. The current MSRV is 1.65.0.

Note that the MSRV is not increased automatically, and only as part of a minor release.

Contributing

Thanks for your help improving the project! We are so happy to have you! We have a contributing guide to help you get involved in the Alloy project.

Pull requests will not be merged unless CI passes, so please ensure that your contribution follows the linting rules and passes clippy.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

block-explorers's People

Contributors

ckoopmann avatar danipopes avatar evalir avatar klkvr avatar mattsse avatar shekhirin avatar yash-atreya avatar zerosnacks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

block-explorers's Issues

Partial Incompatibility with Blockscout

While trying to implement a cast command to migrate a contract verification from on explorer to another (specifically from etherscan to blockscout), I encountered the issue that the contract_source_code and submit_contract_verification methods fail when run against blockscout. (more specifically against "https://eth.blockscout.com/api".

I created tests reproducing the issue for contract_source_code and submit_contract_verification.

Judging from the error messages (see screenshots), the former issue seems to be a pretty strait forward deserialziation issue whereas the latter has a pretty cryptic error message.
image
image

Remove `ethers-core` dependency

Right now we're coupled to ethers due to using RawAbi, and the Chain enum. This means we need to keep patches on foundry to keep ethers versions in sync. We should remove the dep as follows:

  • Integrate alloy-rs/chains when ready
  • Move RawAbi into block-explorers, as it's not an alloy-related type nor an RPC type. It just uses some metadata from the ABI for verification purposes.

Can not deserialize the block number in hex format

Hi, I'm using this library to get the ERC20TokenTransferEvent from etherscan and then save it into a JSON file.
But when deserialize the JSON file, I had this Error value: Error("digit 33 is out of range for base 16", line: 3, column: 39)'. It seems like the number in the JSON file is saved in the hex format.
Can someone help me to solve this issue?

Test code

mod test {
    use std::str::FromStr;

    use alloy_chains::Chain;
    use alloy_primitives::Address;
    use foundry_block_explorers::{account::ERC20TokenTransferEvent, Client};

    #[tokio::test]
    async fn test_serde() {
        let client = Client::new(Chain::from_id(137), "<API-KEY>>").unwrap();
        let addr = Address::from_str("<Address>").unwrap();

        let events = client
            .get_erc20_token_transfer_events(
                foundry_block_explorers::account::TokenQueryOption::ByAddress(addr),
                Some(foundry_block_explorers::account::TxListParams {
                    start_block: 0,
                    end_block: 99999999,
                    page: 1,
                    offset: 1,
                    sort: foundry_block_explorers::account::Sort::Desc,
                }),
            )
            .await
            .unwrap();

        let data = serde_json::to_string_pretty(&events).unwrap();

        println!("{}", data);

        let de_events: Vec<ERC20TokenTransferEvent> = serde_json::from_str(&data).unwrap();

        assert_eq!(events.len(), de_events.len())
    }
}

Cargo.toml

[dependencies]
alloy-chains = "0.1.4"
alloy-primitives = { version = "0.5.2", features = ["serde", "std"] }
alloy-json-abi = { version = "0.5", default-features = false, features = [
    "std",
    "serde_json",
] }
anyhow = "1.0.75"
foundry-block-explorers = "0.1.1"
rust_decimal = { version = "1.33.1", features = ["maths"] }
serde = "1.0.193"
serde_json = "1.0.108"
tokio = { version = "1.34.0", features = ["macros", "rt-multi-thread"] }

Get the settings of verified contract crashes

Some Etherscan verified contracts do not have optimizer field in their compiler settings.
For example, contract 0xd689a304011d64d5bf1d662d9cddf8b2db81e6b6, the compiler settings given by Etherscan is

"settings": {
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "abi"
        ]
      }
    }
  }
}

However, the optimizer field in the Setting struct is not optional, leading to a crash when fetching compiler settings for this contract.
https://github.com/foundry-rs/compilers/blob/342f713da41c9738c6e775b7daf0bf6827041cde/src/artifacts/mod.rs#L266-L273

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.