Skip to content

Transactions

Fetch Ethereum transactions for blocks 17000000 to 17000010.

Code

Rust
use futures::StreamExt;
use std::{collections::HashSet, sync::Arc};
use pangea_client::{
    core::types::ChainId, query::Bound,
    ClientBuilder, Format, WsProvider,
    provider::ChainProvider, requests::txs::GetTxsRequest, 
};
 
#[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 = GetTxsRequest { 
            chains: HashSet::from([ChainId::ETH]), 
            from_block: Bound::Exact(17000000), 
            to_block: Bound::Exact(17000010), 
            ..Default::default() 
        }; 
        let stream = match client 
            .get_txs_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,
    "hash": "0xae76e4d852d8a9d9ebba99787c1ba5859b68bb90a2712cb3e5ce7505a1f8898a",
    "nonce": "0x280",
    "from": "0xe340b00b6b622c136ffa5cff130ec8edcddcb39d",
    "to": "0xb748952c7bc638f31775245964707bcc5ddfabfc",
    "value": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "gas_price": "0x56becd566",
    "gas": "0x169c83",
    "input": "0x3698d492000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bcca60bb61934080951369a648fb03df4f96263c00000000000000000000000000000000000000000000000000000000b93ece4b000000000000000000000000000000000000000000000000000000006430bc4d000000000000000000000000000000000000000000000000000000000000001cb1819b65f3127b333e8e523a33a2ed33dc6e306315355683401e30b269cee64b678fa450b4ec53337a16288cb635c686b21715f1b35daed5a4df84f699cb647c0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b100000000000000000000000000000000000000000000000923b5b069ec4a7bb9000000000000000000000000000000000000000000000000000000006430bc4d000000000000000000000000000000000000000000000000000000000000001cb99e4c3b29e2d597ba5cf77946153591894c0db52824f04a2312e72c9db2ee3a3b9bf6adcfe3510257081616aed6e6e817f0fc7f04ec0ebf122d20bef3c74e060000000000000000000000000000000000000000000000000000000000000000",
    "v": 1,
    "r": "0xb66573801fa159c720731add5f636675f8c3e821c0023f109ade366923cc4052",
    "s": "0xeed3f6f6011e3c6329a6600b11cb176fa0ef48f06ddacc3c1a002c3026113cc",
    "raw": null,
    "type": 2,
    "max_fee_per_gas": "0x716de1b5d",
    "max_priority_fee_per_gas": "0x485ce38"
  }
]

Query Parameters

  • chains: Filters the data by specific blockchain networks.
  • from_block: Filters the data by a starting block_number.
  • to_block: Filters the data by an ending block_number.
  • to__in: Filters the data by a list of to addresses.
  • from__in: Filters the data by a list of from addresses.
  • value__gte: Filters the data by value using the greater than or equal to operator.
  • value__lte: Filters the data by value using the less than or equal to operator.