pub struct Chain;Expand description
Implementations§
Source§impl Chain
impl Chain
Sourcepub fn block_number() -> RequestBuilder<PostprocessHandler<BlockHeight, RpcBlockHandler>>
pub fn block_number() -> RequestBuilder<PostprocessHandler<BlockHeight, RpcBlockHandler>>
Set ups a query to fetch the BlockHeight of the current block
§Fetching the latest block number
use near_api::*;
let block_number = Chain::block_number().fetch_from_testnet().await?;
println!("Current block number: {}", block_number);§Fetching the final block number
use near_api::*;
let block_number = Chain::block_number().at(Reference::Final).fetch_from_testnet().await?;
println!("Final block number: {}", block_number);Sourcepub fn block_hash() -> RequestBuilder<AndThenHandler<CryptoHash, RpcBlockHandler>>
pub fn block_hash() -> RequestBuilder<AndThenHandler<CryptoHash, RpcBlockHandler>>
Set ups a query to fetch the CryptoHash of the block
§Fetching the latest block hash
use near_api::*;
let block_hash = Chain::block_hash().fetch_from_testnet().await?;
println!("Current block hash: {}", block_hash);§Fetching the hash at a specific block number
use near_api::*;
let block_hash = Chain::block_hash().at(Reference::AtBlock(1000000)).fetch_from_testnet().await?;
println!("Block hash at block number 1000000: {}", block_hash);Sourcepub fn block() -> RequestBuilder<RpcBlockHandler>
pub fn block() -> RequestBuilder<RpcBlockHandler>
Set ups a query to fetch the RpcBlockResponse
§Fetching the latest block
use near_api::*;
let block = Chain::block().fetch_from_testnet().await?;
println!("Current block: {:?}", block);§Fetching the block at a specific block number
use near_api::*;
let block = Chain::block().at(Reference::AtBlock(1000000)).fetch_from_testnet().await?;
println!("Block at block number 1000000: {:?}", block);§Fetching the block at a specific block hash
use near_api::*;
let block = Chain::block().at(Reference::AtBlockHash(block_hash)).fetch_from_testnet().await?;
println!("Block at block hash: {:?}", block);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Chain
impl RefUnwindSafe for Chain
impl Send for Chain
impl Sync for Chain
impl Unpin for Chain
impl UnwindSafe for Chain
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
Mutably borrows from an owned value. Read more