Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Failed to get ABI JSON when use abigen! w/ $ETHERSCAN_API_KEY set #589

Closed
b1u3h4t opened this issue Nov 17, 2021 · 4 comments
Closed

Failed to get ABI JSON when use abigen! w/ $ETHERSCAN_API_KEY set #589

b1u3h4t opened this issue Nov 17, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@b1u3h4t
Copy link

b1u3h4t commented Nov 17, 2021

Version

[root@iZrj923msgidyk7ob4pwzgZ ethers-rs]# cargo tree | grep ethers
ethers-contract v0.5.3 (/root/rust/ethers-rs/ethers-contract)
├── ethers-contract-abigen v0.5.3 (/root/rust/ethers-rs/ethers-contract/ethers-contract-abigen)
│   ├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core)
├── ethers-contract-derive v0.5.3 (proc-macro) (/root/rust/ethers-rs/ethers-contract/ethers-contract-derive)
│   ├── ethers-contract-abigen v0.5.3 (/root/rust/ethers-rs/ethers-contract/ethers-contract-abigen) (*)
│   ├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
├── ethers-derive-eip712 v0.1.0 (proc-macro) (/root/rust/ethers-rs/ethers-core/ethers-derive-eip712)
│   ├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
├── ethers-providers v0.5.4 (/root/rust/ethers-rs/ethers-providers)
│   ├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
├── ethers-contract-abigen v0.5.3 (/root/rust/ethers-rs/ethers-contract/ethers-contract-abigen) (*)
├── ethers-contract-derive v0.5.3 (proc-macro) (/root/rust/ethers-rs/ethers-contract/ethers-contract-derive) (*)
├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
├── ethers-derive-eip712 v0.1.0 (proc-macro) (/root/rust/ethers-rs/ethers-core/ethers-derive-eip712) (*)
├── ethers-middleware v0.5.3 (/root/rust/ethers-rs/ethers-middleware)
│   ├── ethers-contract v0.5.3 (/root/rust/ethers-rs/ethers-contract) (*)
│   ├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
│   ├── ethers-providers v0.5.4 (/root/rust/ethers-rs/ethers-providers) (*)
│   ├── ethers-signers v0.5.3 (/root/rust/ethers-rs/ethers-signers)
│   │   ├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
│   │   ├── ethers-contract v0.5.3 (/root/rust/ethers-rs/ethers-contract) (*)
│   │   ├── ethers-derive-eip712 v0.1.0 (proc-macro) (/root/rust/ethers-rs/ethers-core/ethers-derive-eip712) (*)
│   ├── ethers-providers v0.5.4 (/root/rust/ethers-rs/ethers-providers) (*)
│   ├── ethers-solc v0.1.0 (/root/rust/ethers-rs/ethers-solc)
│   │   ├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
├── ethers-providers v0.5.4 (/root/rust/ethers-rs/ethers-providers) (*)
├── ethers-signers v0.5.3 (/root/rust/ethers-rs/ethers-signers) (*)
├── ethers-solc v0.1.0 (/root/rust/ethers-rs/ethers-solc) (*)
ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
ethers-etherscan v0.1.1 (/root/rust/ethers-rs/ethers-etherscan)
├── ethers-core v0.5.5 (/root/rust/ethers-rs/ethers-core) (*)
ethers-middleware v0.5.3 (/root/rust/ethers-rs/ethers-middleware) (*)
ethers-providers v0.5.4 (/root/rust/ethers-rs/ethers-providers) (*)
ethers-signers v0.5.3 (/root/rust/ethers-rs/ethers-signers) (*)
ethers-solc v0.1.0 (/root/rust/ethers-rs/ethers-solc) (*)

Platform
Linux

Description
failed to get ABI JSON when use abigen! w/ $ETHERSCAN_API_KEY set

[root@iZrj923msgidyk7ob4pwzgZ ethers-rs]# cargo run --example contract_with_abi -p ethers
   Compiling ethers v0.5.4 (/root/rust/ethers-rs)
error: failed to get ABI JSON
  --> examples/contract_with_abi.rs:15:5
   |
15 |     "https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f"
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `ethers` due to previous error

I tried this code:

[root@iZrj923msgidyk7ob4pwzgZ ethers-rs]# git diff
diff --git a/examples/contract_with_abi.rs b/examples/contract_with_abi.rs
index 83af2d9..21b04be 100644
--- a/examples/contract_with_abi.rs
+++ b/examples/contract_with_abi.rs
@@ -10,6 +10,11 @@ abigen!(
     event_derives(serde::Deserialize, serde::Serialize)
 );
 
+abigen!(
+    DAI,
+    "https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f"
+);
+
 #[tokio::main]
 async fn main() -> Result<()> {
     // 1. compile the contract (note this requires that you are inside the `examples` directory) and
@b1u3h4t b1u3h4t added the bug Something isn't working label Nov 17, 2021
@gakonst
Copy link
Owner

gakonst commented Nov 17, 2021

Can you try the below code?

abigen!(
     DAI,
     "etherscan:0x6b175474e89094c44da98b954eedeac495271d0f"
);

@b1u3h4t
Copy link
Author

b1u3h4t commented Nov 17, 2021

[root@iZrj923msgidyk7ob4pwzgZ ethers-rs]# export ETHERSCAN_API_KEY=4Z9TGJ2BF1WSHCP6Q5G8CREFM5IQR92ZYX
[root@iZrj923msgidyk7ob4pwzgZ ethers-rs]# cargo run --example contract_with_abi -p ethers
   Compiling ethers v0.5.4 (/root/rust/ethers-rs)
error: failed to get ABI JSON
  --> examples/contract_with_abi.rs:20:5
   |
20 |     "etherscan:0x6b175474e89094c44da98b954eedeac495271d0f"
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `ethers` due to previous error

Same error. Any features wrong?

@gakonst
Copy link
Owner

gakonst commented Nov 17, 2021

I believe this is related to this commit: d53ca0e cc @mattsse.

We're hitting the Err case here when we shouldn't be:

 cfg_if! {
        if #[cfg(any(not(target_arch = "wasm32"), not(features = "reqwest")))]{
            Err(anyhow!("HTTP is unsupported"))
        } else {
            Ok(reqwest::blocking::get(_url)?.text()?)
        }
    }

@gakonst
Copy link
Owner

gakonst commented Nov 29, 2021

Fixed in #632

@gakonst gakonst closed this as completed Nov 29, 2021
meetmangukiya pushed a commit to meetmangukiya/ethers-rs that referenced this issue Mar 21, 2022
Currently all of our releases have no description, because
our changelog builder action hides uncategorized PRs by default.

This configures the action to show the uncategorized PRs under
a special section called "Other", and it also configures the
labels required for the other sections of the changelog:

- Feature PRs should now be tagged with `T-feature`
- Bug fix PRs should be tagged with `T-bug`
- To omit a PR entirely from the changelog, add `L-ignore` to
  the PR.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants