foundry-rs / block-explorers Goto Github PK
View Code? Open in Web Editor NEWBindings for the etherscan API and other block explorers.
License: Apache License 2.0
Bindings for the etherscan API and other block explorers.
License: Apache License 2.0
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?
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())
}
}
[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"] }
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.
Hi all!
I was checking the code of block explorer, but realize some tricky issues.
block-explorers/crates/block-explorers/src/contract.rs
Lines 413 to 430 in 1f442fe
Based on the code, it seems if the cache.get_source(address)
returns None
, the function will throw ContractCodeNotVerified
errors.
However, based on the code of cache, there is another possibility that the contract is verified, but the cache is not alive. In that case, the function may misbehave.
block-explorers/crates/block-explorers/src/lib.rs
Lines 472 to 480 in 1f442fe
Please let me know if I misunderstood anything here. I am more than happy to open a PR if this is indeed an issue.
Thanks!
with #42 we now have a few blobscan api functions but we're missing a few more
as well as partial responses for queries
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:
alloy-rs/chains
when readyRawAbi
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.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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.