We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bd19016 commit 8af1ee9Copy full SHA for 8af1ee9
api/examples/specifying_block.rs
@@ -2,14 +2,18 @@ use near_api::{Chain, types::Reference};
2
3
#[tokio::main]
4
async fn main() -> testresult::TestResult {
5
- // Fetch a single final block
6
- let final_block = Chain::block()
+ // Fetch a optimistic block
+ let _optimistic_block = Chain::block().fetch_from_mainnet().await?;
7
+
8
+ let block_number = Chain::block_number()
9
.at(Reference::Final)
10
.fetch_from_mainnet()
11
.await?;
12
- let block_number = final_block.header.height;
- let block_hash = final_block.header.hash.into();
13
+ let block_hash = Chain::block_hash()
14
+ .at(Reference::Final)
15
+ .fetch_from_mainnet()
16
+ .await?;
17
18
let _block_by_number = Chain::block()
19
.at(Reference::AtBlock(block_number))
0 commit comments