pub struct Client { /* private fields */ }
Expand description
Client for Blobscan API
See also Blobscan API Documentation
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(baseurl: impl Into<String>) -> Self
pub fn new(baseurl: impl Into<String>) -> Self
Create a new client.
baseurl
is the base URL provided to the internal reqwest::Client
Sourcepub fn new_chain(chain: Chain) -> Option<Self>
pub fn new_chain(chain: Chain) -> Option<Self>
Create a new client instance for blobscan.com
with the correct endpoint based on the
chain.
At this time, only the following chains are supported by Blobscan:
- Ethereum Mainnet: https://api.blobscan.com/
- Sepolia Testnet: https://api.sepolia.blobscan.com/
- Holesky Testnet: https://api.holesky.blobscan.com/
For other chains this will return None
Sourcepub fn new_chain_with_client(chain: Chain, client: Client) -> Option<Self>
pub fn new_chain_with_client(chain: Chain, client: Client) -> Option<Self>
Create a new client instance for blobscan.com
with the given reqwest::Client and the
correct endpoint based on the chain.
At this time, only the following chains are supported by Blobscan:
- Ethereum Mainnet: https://api.blobscan.com/
- Sepolia Testnet: https://api.sepolia.blobscan.com/
- Holesky Testnet: https://api.holesky.blobscan.com/
For other chains this will return None
Sourcepub fn mainnet() -> Self
pub fn mainnet() -> Self
Creates a new client instance for the Ethereum Mainnet with the correct endpoint: https://api.blobscan.com/
Sourcepub fn sepolia() -> Self
pub fn sepolia() -> Self
Creates a new client instance for the sepolia Testnet with the correct endpoint: https://api.sepolia.blobscan.com/
Sourcepub fn holesky() -> Self
pub fn holesky() -> Self
Creates a new client instance for the holesky Testnet with the correct endpoint: https://api.holesky.blobscan.com/
Sourcepub fn mainnet_with_client(client: Client) -> Self
pub fn mainnet_with_client(client: Client) -> Self
Creates a new client instance for the Ethereum Mainnet with the given reqwest::Client and the correct endpoint: https://api.blobscan.com/
Sourcepub fn sepolia_with_client(client: Client) -> Self
pub fn sepolia_with_client(client: Client) -> Self
Creates a new client instance for the sepolia Testnet with the given reqwest::Client and the correct endpoint: https://api.sepolia.blobscan.com/
Sourcepub fn holesky_with_client(client: Client) -> Self
pub fn holesky_with_client(client: Client) -> Self
Creates a new client instance for the holesky Testnet with the given reqwest::Client and the correct endpoint: https://api.holesky.blobscan.com/
Sourcepub fn new_with_client(baseurl: impl Into<String>, client: Client) -> Self
pub fn new_with_client(baseurl: impl Into<String>, client: Client) -> Self
Construct a new client with an existing reqwest::Client allowing more control over its configuration.
baseurl
is the base URL provided to the internal
Sourcepub async fn transaction(&self, tx_hash: B256) -> Result<TransactionDetails>
pub async fn transaction(&self, tx_hash: B256) -> Result<TransactionDetails>
Retrieves the full transaction details for given block transaction hash.
Sends a GET
request to /transactions/{hash}
§Example
use alloy_primitives::b256;
use foundry_blob_explorers::Client;
let client = Client::holesky();
let tx = client
.transaction(b256!("d4f136048a56b9b62c9cdca0ce0dbb224295fd0e0170dbbc78891d132f639d60"))
.await
.unwrap();
println!("[{}] blob: {:?}", tx.hash, tx.blob_sidecar());
Sourcepub async fn transaction_with_query(
&self,
tx_hash: B256,
query: GetTransactionQuery,
) -> Result<TransactionDetails>
pub async fn transaction_with_query( &self, tx_hash: B256, query: GetTransactionQuery, ) -> Result<TransactionDetails>
Retrieves the specific transaction details for given transaction hash.
Sends a GET
request to /transactions/{hash}
Sourcepub async fn block(
&self,
block: BlockHashOrNumber,
) -> Result<BlockResponse<FullTransactionDetails>>
pub async fn block( &self, block: BlockHashOrNumber, ) -> Result<BlockResponse<FullTransactionDetails>>
Retrieves the full block details for given block number or hash.
Sends a GET
request to /blocks/{id}
§Example
use foundry_blob_explorers::Client;
let client = Client::holesky();
let block = client
.block(
"0xc3a0113f60107614d1bba950799903dadbc2116256a40b1fefb37e9d409f1866".parse().unwrap(),
)
.await
.unwrap();
for (tx, sidecar) in block.blob_sidecars() {
println!("[{}] blob: {:?}", tx, sidecar);
}
Sourcepub async fn block_with_query(
&self,
block: BlockHashOrNumber,
query: GetBlockQuery,
) -> Result<BlockResponse<SelectedTransactionDetails>>
pub async fn block_with_query( &self, block: BlockHashOrNumber, query: GetBlockQuery, ) -> Result<BlockResponse<SelectedTransactionDetails>>
Retrieves the specific block details for given block number or hash.
Sends a GET
request to /blocks/{id}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more