Struct gemblockchain::node::Node
source · pub struct Node<'a> { /* private fields */ }
Expand description
Node
client for executing asynchronous requests.
Node
client has url as the configuration value, but the default is set to what is usually the most commonly desired value. Use Node::from_url()
to create the node client.
Implementations§
source§impl<'a> Node<'a>
impl<'a> Node<'a>
sourcepub fn from_url(url: &'a str) -> Self
pub fn from_url(url: &'a str) -> Self
Create an Node
from url string.
Examples found in repository?
More examples
examples/get_assets_details.rs (line 5)
4 5 6 7 8 9 10 11 12 13 14 15
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
// Tether USD token
let result = node
.get_assets_details("34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ")
.await?;
println!("{:?}", result);
Ok(())
}
examples/get_blocks.rs (line 5)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node.get_blocks_last().await?;
println!("{:?}", result);
let result = node
.get_blocks_headers_at_height(result.height() - 10)
.await?;
println!("{:?}", result);
let result = node.get_blocks_headers(&result.id()).await?;
println!("{:?}", result);
Ok(())
}
examples/get_transactions.rs (line 5)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_transactions_info("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
.await?;
println!("{:?}", result);
let result = node
.get_transactions_status("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
.await?;
println!("{}", result.status());
Ok(())
}
Additional examples can be found in:
sourcepub async fn get_balance(
&self,
address: &str
) -> Result<ResponseBalance, Box<dyn Error>>
pub async fn get_balance( &self, address: &str ) -> Result<ResponseBalance, Box<dyn Error>>
Get the regular balance in WAVES at a given address
use gemblockchain::node::{Node, MAINNET_URL};
use gemblockchain::util::Amount;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_balance("3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv")
.await?;
let balance = Amount::from_wavelet(result.balance());
println!("Balance: {} WAVES", balance);
Ok(())
}
Examples found in repository?
examples/get_balance.rs (line 10)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
// If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.
let result = node
.get_balance("3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv")
.await?;
let balance = Amount::from_wavelet(result.balance());
println!("Balance: {} WAVES", balance);
let result = node
.get_balance_details("3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv")
.await?;
let balance = Amount::from_wavelet(result.regular());
println!("Regular balance: {} WAVES", balance);
Ok(())
}
sourcepub async fn get_balance_details(
&self,
address: &str
) -> Result<ResponseBalanceDetails, Box<dyn Error>>
pub async fn get_balance_details( &self, address: &str ) -> Result<ResponseBalanceDetails, Box<dyn Error>>
Get the available, regular, generating, and effective balance
use gemblockchain::node::{Node, MAINNET_URL};
use gemblockchain::util::Amount;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_balance_details("3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv")
.await?;
let balance = Amount::from_wavelet(result.regular());
println!("Regular balance: {} WAVES", balance);
Ok(())
}
Examples found in repository?
examples/get_balance.rs (line 18)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
// If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.
let result = node
.get_balance("3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv")
.await?;
let balance = Amount::from_wavelet(result.balance());
println!("Balance: {} WAVES", balance);
let result = node
.get_balance_details("3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv")
.await?;
let balance = Amount::from_wavelet(result.regular());
println!("Regular balance: {} WAVES", balance);
Ok(())
}
sourcepub async fn get_address_by_alias(
&self,
alias: &str
) -> Result<ResponseAddress, Box<dyn Error>>
pub async fn get_address_by_alias( &self, alias: &str ) -> Result<ResponseAddress, Box<dyn Error>>
Get an address associated with a given alias.
use gemblockchain::node::{Node, MAINNET_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node.get_address_by_alias("vlzhr").await?;
println!("vlzhr -> {}", result.address());
Ok(())
}
sourcepub async fn get_assets_details(
&self,
asset_id: &str
) -> Result<ResponseAsset, Box<dyn Error>>
pub async fn get_assets_details( &self, asset_id: &str ) -> Result<ResponseAsset, Box<dyn Error>>
Get detailed information about given asset
use gemblockchain::node::{Node, MAINNET_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_assets_details("34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ")
.await?;
println!("{:?}", result);
Ok(())
}
Examples found in repository?
examples/get_assets_details.rs (line 9)
4 5 6 7 8 9 10 11 12 13 14 15
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
// Tether USD token
let result = node
.get_assets_details("34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ")
.await?;
println!("{:?}", result);
Ok(())
}
sourcepub async fn get_blocks_headers(
&self,
id: &str
) -> Result<ResponseBlock, Box<dyn Error>>
pub async fn get_blocks_headers( &self, id: &str ) -> Result<ResponseBlock, Box<dyn Error>>
Get headers of a given block
use gemblockchain::node::{Node, MAINNET_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_blocks_headers("3cBRMpKHjPNKUXkgGJNGAaPviY4LmE8urTwd4B2J8v9M")
.await?;
println!("{:?}", result);
Ok(())
}
Examples found in repository?
examples/get_blocks.rs (line 17)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node.get_blocks_last().await?;
println!("{:?}", result);
let result = node
.get_blocks_headers_at_height(result.height() - 10)
.await?;
println!("{:?}", result);
let result = node.get_blocks_headers(&result.id()).await?;
println!("{:?}", result);
Ok(())
}
sourcepub async fn get_blocks_headers_at_height(
&self,
height: u64
) -> Result<ResponseBlock, Box<dyn Error>>
pub async fn get_blocks_headers_at_height( &self, height: u64 ) -> Result<ResponseBlock, Box<dyn Error>>
Get headers of a given block
use gemblockchain::node::{Node, MAINNET_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node.get_blocks_headers_at_height(3341874).await?;
println!("{:?}", result);
Ok(())
}
Examples found in repository?
examples/get_blocks.rs (line 12)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node.get_blocks_last().await?;
println!("{:?}", result);
let result = node
.get_blocks_headers_at_height(result.height() - 10)
.await?;
println!("{:?}", result);
let result = node.get_blocks_headers(&result.id()).await?;
println!("{:?}", result);
Ok(())
}
sourcepub async fn get_blocks_last(&self) -> Result<ResponseBlock, Box<dyn Error>>
pub async fn get_blocks_last(&self) -> Result<ResponseBlock, Box<dyn Error>>
Get the block at the current blockchain height
use gemblockchain::node::{Node, MAINNET_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node.get_blocks_last().await?;
println!("{:?}", result);
Ok(())
}
Examples found in repository?
examples/get_blocks.rs (line 7)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node.get_blocks_last().await?;
println!("{:?}", result);
let result = node
.get_blocks_headers_at_height(result.height() - 10)
.await?;
println!("{:?}", result);
let result = node.get_blocks_headers(&result.id()).await?;
println!("{:?}", result);
Ok(())
}
sourcepub async fn get_leasing_info(
&self,
id: &str
) -> Result<ResponseLease, Box<dyn Error>>
pub async fn get_leasing_info( &self, id: &str ) -> Result<ResponseLease, Box<dyn Error>>
Get lease parameters by lease ID
use gemblockchain::node::{Node, MAINNET_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_leasing_info("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
.await?;
println!("{:?}", result);
Ok(())
}
sourcepub async fn get_node_version(
&self
) -> Result<ResponseNodeVersion, Box<dyn Error>>
pub async fn get_node_version( &self ) -> Result<ResponseNodeVersion, Box<dyn Error>>
Get node version
use gemblockchain::node::{Node, MAINNET_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node.get_node_version().await?;
println!("Version: {}", result.version());
Ok(())
}
sourcepub async fn get_transactions_info(
&self,
id: &str
) -> Result<ResponseTransaction, Box<dyn Error>>
pub async fn get_transactions_info( &self, id: &str ) -> Result<ResponseTransaction, Box<dyn Error>>
Get a transaction by its ID
use gemblockchain::node::{Node, MAINNET_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_transactions_info("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
.await?;
println!("{:?}", result);
Ok(())
}
Examples found in repository?
examples/get_transactions.rs (line 8)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_transactions_info("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
.await?;
println!("{:?}", result);
let result = node
.get_transactions_status("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
.await?;
println!("{}", result.status());
Ok(())
}
sourcepub async fn get_transactions_status(
&self,
id: &str
) -> Result<ResponseTransactionStatus, Box<dyn Error>>
pub async fn get_transactions_status( &self, id: &str ) -> Result<ResponseTransactionStatus, Box<dyn Error>>
Get transaction status by its ID
use gemblockchain::node::{Node, MAINNET_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_transactions_status("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
.await?;
println!("{:?}", result);
Ok(())
}
Examples found in repository?
examples/get_transactions.rs (line 14)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let node = Node::from_url(MAINNET_URL);
let result = node
.get_transactions_info("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
.await?;
println!("{:?}", result);
let result = node
.get_transactions_status("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
.await?;
println!("{}", result.status());
Ok(())
}
Trait Implementations§
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Node<'a>
impl<'a> Send for Node<'a>
impl<'a> Sync for Node<'a>
impl<'a> Unpin for Node<'a>
impl<'a> UnwindSafe for Node<'a>
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