Logs
Fetch Ethereum logs for blocks 17000000
to 17000010
.
Rust
use futures::StreamExt;
use std::{collections::HashSet, sync::Arc};
use pangea_client::{
core::types::ChainId, query::Bound,
ClientBuilder, Format, WsProvider,
provider::ChainProvider, requests::logs::GetLogsRequest,
};
#[tokio::main]
async fn main() {
dotenvy::dotenv_override().ok();
let client = match ClientBuilder::default()
.endpoint("app.pangea.foundation")
.build::<WsProvider>()
.await
{
Ok(client) => Arc::new(client),
Err(e) => {
eprintln!("Client failed to initialize:\n{e}");
return;
}
};
{
let request = GetLogsRequest {
chains: HashSet::from([ChainId::ETH]),
from_block: Bound::Exact(17000000),
to_block: Bound::Exact(17000010),
..Default::default()
};
let stream = match client
.get_logs_by_format(request, Format::JsonStream, false)
.await
{
Ok(stream) => stream,
Err(e) => {
eprintln!("Request failed\n{e}");
return;
}
};
futures::pin_mut!(stream);
while let Some(chunk) = stream.next().await {
let chunk = String::from_utf8(chunk.unwrap()).unwrap();
println!("{chunk}");
}
}
}
Response
[
...
{
"chain": 1,
"block_number": "0x103664a",
"block_hash": "0x5bad63a542b4deebf2d8ba93bf83b98a96ac4693640dfc3c2ccec38c3adc2bf2",
"transaction_index": 253,
"transaction_hash": "0xae76e4d852d8a9d9ebba99787c1ba5859b68bb90a2712cb3e5ce7505a1f8898a",
"log_index": "0x15c",
"address": "0x87870bca3f3fd6335c3f4ce8392d69350b4fa4e2",
"topic0": "0x2b627736bca15cd5381dcf80b0bf11fd197d01a037c52b927a881a10fb73ba61",
"topic1": "0x000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52",
"topic2": "0x000000000000000000000000e340b00b6b622c136ffa5cff130ec8edcddcb39d",
"topic3": "0x0000000000000000000000000000000000000000000000000000000000000000",
"data": "0x000000000000000000000000b748952c7bc638f31775245964707bcc5ddfabfc000000000000000000000000000000000000000000000009215f570e12dcdd93",
"removed": false
}
]
Query Parameters
chains
: Filters the data by specific blockchain networks.from_block
: Filters the data by a startingblock_number
.to_block
: Filters the data by an endingblock_number
.address__in
: Filters the data by a list of contractaddress
.topic0__in
: Filters the data by a list oftopic0
valuestopic1__in
: Filters the data by a list oftopic1
valuestopic2__in
: Filters the data by a list oftopic2
valuestopic3__in
: Filters the data by a list oftopic3
values