-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
660a732
commit 43424bd
Showing
11 changed files
with
621 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use starknet::providers::{ | ||
jsonrpc::{HttpTransport, JsonRpcClient}, | ||
Provider, ProviderRequestData, ProviderResponseData, Url, | ||
}; | ||
use starknet_core::types::{ | ||
requests::{BlockNumberRequest, GetBlockTransactionCountRequest}, | ||
BlockId, | ||
}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let provider = JsonRpcClient::new(HttpTransport::new( | ||
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(), | ||
)); | ||
|
||
let responses = provider | ||
.batch_requests([ | ||
ProviderRequestData::BlockNumber(BlockNumberRequest), | ||
ProviderRequestData::GetBlockTransactionCount(GetBlockTransactionCountRequest { | ||
block_id: BlockId::Number(100), | ||
}), | ||
]) | ||
.await | ||
.unwrap(); | ||
|
||
match (&responses[0], &responses[1]) { | ||
( | ||
ProviderResponseData::BlockNumber(block_number), | ||
ProviderResponseData::GetBlockTransactionCount(count), | ||
) => { | ||
println!("The latest block is #{}", block_number); | ||
println!("Block #100 has {} transactions", count); | ||
} | ||
_ => panic!("unexpected response type"), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.