Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shekohex/ethers-etherscan-issue
Reproducing an issue with ethers-rs Etherscan's API
https://github.com/shekohex/ethers-etherscan-issue
Last synced: about 1 month ago
JSON representation
Reproducing an issue with ethers-rs Etherscan's API
- Host: GitHub
- URL: https://github.com/shekohex/ethers-etherscan-issue
- Owner: shekohex
- Created: 2023-04-05T12:03:08.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-13T17:09:24.000Z (over 1 year ago)
- Last Synced: 2024-04-13T22:58:40.077Z (7 months ago)
- Language: Rust
- Homepage: https://github.com/gakonst/ethers-rs/issues/2324
- Size: 51.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### ethers-rs Etherscan API issue
An issue with etherscan API while using `[email protected]` crate.
### Steps to Reproduce
1. Clone the repo: `git clone https://github.com/shekohex/ethers-etherscan-issue.git`
2. Set `ETHERSCAN_API_KEY` env variable with your etherscan API key. (for our case, use Polygon API key)
3. Set `CHAIN` env variable with the chain you want to use (for our case `polygon`).
4. Run `cargo run`### Expected Behavior
The program should print the Gas Oracle data.
### Actual Behavior
**It Returns an error**
```rs
ERROR etherscan: Failed to deserialize response: data did not match any variant of untagged enum ResponseData, res: "{\"status\":\"1\",\"message\":\"OK\",\"result\":{\"LastBlock\":\"41171167\",\"SafeGasPrice\":\"119.9\",\"ProposeGasPrice\":\"141.9\",\"FastGasPrice\":\"142.9\",\"suggestBaseFee\":\"89.82627877\",\"gasUsedRatio\":\"0.399191166666667,0.4847166,0.997667533333333,0.538075133333333,0.343416033333333\",\"UsdPrice\":\"1.15\"}}"
at /home/shady/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ethers-etherscan-2.0.2/src/lib.rs:205INFO ethers_etherscan_issue: Gas Oracle Info, gas_oracle: Err(Serde(Error("data did not match any variant of untagged enum ResponseData", line: 0, column: 0)))
at src/main.rs:39
```**JSON Response**
```json
{
"status": "1",
"message": "OK",
"result": {
"LastBlock": "41171167",
"SafeGasPrice": "119.9",
"ProposeGasPrice": "141.9",
"FastGasPrice": "142.9",
"suggestBaseFee": "89.82627877",
"gasUsedRatio": "0.399191166666667,0.4847166,0.997667533333333,0.538075133333333,0.343416033333333",
"UsdPrice": "1.15"
}
}
```### Environment
- Operating System: `Linux workstation 5.15.104-2-MANJARO #1 SMP PREEMPT Thu Mar 23 01:40:42 UTC 2023 x86_64 GNU/Linux`
- Ethers Version: `2.0.2`