pub struct Node { /* private fields */ }
Implementations§
Source§impl Node
impl Node
Sourcepub fn from_profile(profile: Profile) -> Node
pub fn from_profile(profile: Profile) -> Node
Creates node structure from Profile to interact with Waves node through REST-API
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let addresses = node.get_addresses().await.unwrap();
println!("{:?}", addresses);
}
Sourcepub fn from_url(url: Url, chain_id: u8) -> Node
pub fn from_url(url: Url, chain_id: u8) -> Node
Creates node structure from Url to interact with Waves node through REST-API
use url::Url;
use waves_rust::api::Node;
use waves_rust::model::ChainId;
#[tokio::main]
async fn main() {
let url = Url::parse("https://nodes-testnet.wavesnodes.com").unwrap();
let node = Node::from_url(url, ChainId::TESTNET.byte());
let addresses = node.get_addresses().await.unwrap();
println!("{:?}", addresses);
}
pub fn url(&self) -> Url
pub fn chain_id(&self) -> u8
Sourcepub async fn get_addresses(&self) -> Result<Vec<Address>>
pub async fn get_addresses(&self) -> Result<Vec<Address>>
Get a list of account addresses in the node wallet
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let addresses = node.get_addresses().await.unwrap();
println!("{:?}", addresses);
}
Sourcepub async fn get_addresses_seq(
&self,
from_index: u64,
to_index: u64,
) -> Result<Vec<Address>>
pub async fn get_addresses_seq( &self, from_index: u64, to_index: u64, ) -> Result<Vec<Address>>
Get a list of account addresses in the node wallet
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let addresses = node.get_addresses_seq(0, 1).await.unwrap();
println!("{:?}", addresses);
}
Sourcepub async fn get_balance(&self, address: &Address) -> Result<u64>
pub async fn get_balance(&self, address: &Address) -> Result<u64>
Get the regular balance in WAVES at a given address
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let balance = node.get_balance(&address).await.unwrap();
println!("{}", balance);
}
Sourcepub async fn get_balance_with_confirmations(
&self,
address: &Address,
confirmations: u32,
) -> Result<u64>
pub async fn get_balance_with_confirmations( &self, address: &Address, confirmations: u32, ) -> Result<u64>
Get the minimum regular balance at a given address for confirmations blocks back from the current height
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let balance = node.get_balance_with_confirmations(&address, 100).await.unwrap();
println!("{}", balance);
}
Sourcepub async fn get_balances(&self, addresses: &[Address]) -> Result<Vec<Balance>>
pub async fn get_balances(&self, addresses: &[Address]) -> Result<Vec<Balance>>
Get regular balances for multiple addresses
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address1 = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let address2 = Address::from_string("3N2yqTEKArWS3ySs2f6t8fpXdjX6cpPuhG8").unwrap();
let balances = node.get_balances(&[address1, address2]).await.unwrap();
println!("{}", balances);
}
Sourcepub async fn get_balances_at_height(
&self,
addresses: &[Address],
height: u32,
) -> Result<Vec<Balance>>
pub async fn get_balances_at_height( &self, addresses: &[Address], height: u32, ) -> Result<Vec<Balance>>
Get regular balances for multiple addresses at the given height
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let height = node.get_height().await.unwrap();
let address1 = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let address2 = Address::from_string("3N2yqTEKArWS3ySs2f6t8fpXdjX6cpPuhG8").unwrap();
let balances = node.get_balances_at_height(&[address1, address2], height - 10).await.unwrap();
println!("{}", balances);
}
Sourcepub async fn get_balance_details(
&self,
address: &Address,
) -> Result<BalanceDetails>
pub async fn get_balance_details( &self, address: &Address, ) -> Result<BalanceDetails>
Get the available, regular, generating, and effective balance
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let balance_details = node.get_balance_details(&address).await.unwrap();
println!("{:?}", balance_details);
}
Sourcepub async fn get_data(&self, address: &Address) -> Result<Vec<DataEntry>>
pub async fn get_data(&self, address: &Address) -> Result<Vec<DataEntry>>
Read account data entries
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let account_data = node.get_data(&address).await.unwrap();
println!("{:?}", account_data);
}
Sourcepub async fn get_data_by_keys(
&self,
address: &Address,
keys: &[&str],
) -> Result<Vec<DataEntry>>
pub async fn get_data_by_keys( &self, address: &Address, keys: &[&str], ) -> Result<Vec<DataEntry>>
Read account data entries by given keys
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let account_data = node.get_data_by_keys(&address, &["bool", "int"]).await.unwrap();
println!("{:?}", account_data);
}
Sourcepub async fn get_data_by_regex(
&self,
address: &Address,
regex: &Regex,
) -> Result<Vec<DataEntry>>
pub async fn get_data_by_regex( &self, address: &Address, regex: &Regex, ) -> Result<Vec<DataEntry>>
Read account data entries by given regular expression
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
use regex::Regex;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let regex = Regex::new(r"b\w+").unwrap();
let account_data = node.get_data_by_regex(&address, ®ex).await.unwrap();
println!("{:?}", account_data);
}
Sourcepub async fn get_data_by_key(
&self,
address: &Address,
key: &str,
) -> Result<DataEntry>
pub async fn get_data_by_key( &self, address: &Address, key: &str, ) -> Result<DataEntry>
Read account data entry by given key
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let account_data = node.get_data_by_key(&address, "int").await.unwrap();
println!("{:?}", account_data);
}
Sourcepub async fn get_script_info(&self, address: &Address) -> Result<ScriptInfo>
pub async fn get_script_info(&self, address: &Address) -> Result<ScriptInfo>
Get an account script or a dApp script with additional info by a given address
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mv1HwsRtMjyGKSe5DSDnbT2AoTsXAjtwZS").unwrap();
let script_info = node.get_script_info(&address).await.unwrap();
println!("{:?}", script_info);
}
Sourcepub async fn get_script_meta(&self, address: &Address) -> Result<ScriptMeta>
pub async fn get_script_meta(&self, address: &Address) -> Result<ScriptMeta>
Get an account script meta
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mv1HwsRtMjyGKSe5DSDnbT2AoTsXAjtwZS").unwrap();
let script_meta = node.get_script_meta(&address).await.unwrap();
println!("{:?}", script_meta);
}
Sourcepub async fn get_aliases_by_address(
&self,
address: &Address,
) -> Result<AliasesByAddressResponse>
pub async fn get_aliases_by_address( &self, address: &Address, ) -> Result<AliasesByAddressResponse>
Get a list of aliases associated with a given address
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3MxtrLkrbcG28uTvmbKmhrwGrR65ooHVYvK").unwrap();
let aliases = node.get_aliases_by_address(&address).await.unwrap();
println!("{:?}", aliases);
}
Sourcepub async fn get_address_by_alias(&self, alias: &Alias) -> Result<Address>
pub async fn get_address_by_alias(&self, alias: &Alias) -> Result<Address>
Get an address associated with a given alias. Alias should be plain text without an ‘alias’ prefix and chain ID
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Alias, ChainId};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let alias = Alias::new(ChainId::TESTNET.byte(), "alias1662650000377").unwrap();
let address = node.get_address_by_alias(&alias).await.unwrap();
println!("{:?}", address);
}
Sourcepub async fn get_asset_distribution(
&self,
asset_id: &AssetId,
height: u32,
limit: u16,
after: Option<Address>,
) -> Result<AssetDistribution>
pub async fn get_asset_distribution( &self, asset_id: &AssetId, height: u32, limit: u16, after: Option<Address>, ) -> Result<AssetDistribution>
Get asset balance distribution by addresses at a given height
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address, AssetId, ChainId};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let height = node.get_height().await.unwrap();
let asset_id = AssetId::from_string("DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p").unwrap();
let after = Address::from_string("3P2iT1nawotR2QWmjfMAm18xytUiK6cWtHt").unwrap();
let address = node.get_asset_distribution(&asset_id, height, 10, Some(after)).await.unwrap();
println!("{:?}", address);
}
Sourcepub async fn get_assets_balance(
&self,
address: &Address,
) -> Result<AssetsBalanceResponse>
pub async fn get_assets_balance( &self, address: &Address, ) -> Result<AssetsBalanceResponse>
Get account balances in all or specified assets (excluding WAVES) at a given address. Note: Full portfolio also excludes NFTs.
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3MxtrLkrbcG28uTvmbKmhrwGrR65ooHVYvK").unwrap();
let assets_balance = node.get_assets_balance(&address).await.unwrap();
println!("{:?}", assets_balance);
}
Sourcepub async fn get_asset_balance(
&self,
address: &Address,
asset_id: &AssetId,
) -> Result<u64>
pub async fn get_asset_balance( &self, address: &Address, asset_id: &AssetId, ) -> Result<u64>
Get account balances in all or specified assets (excluding WAVES) at a given address. Note: Full portfolio also excludes NFTs.
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address};
#[tokio::main]
async fn main() {
use waves_rust::model::AssetId;
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3MxtrLkrbcG28uTvmbKmhrwGrR65ooHVYvK").unwrap();
let asset_id = AssetId::from_string("8bt2MZjuUCJPmfucPfaZPTXqrxmoCHCC8gVnbjZ7bhH6").unwrap();
let asset_balance = node.get_asset_balance(&address, &asset_id).await.unwrap();
println!("{:?}", asset_balance);
}
Sourcepub async fn get_asset_details(
&self,
asset_id: &AssetId,
) -> Result<AssetDetails>
pub async fn get_asset_details( &self, asset_id: &AssetId, ) -> Result<AssetDetails>
Get detailed information about given asset
use waves_rust::api::{Node, Profile};
use waves_rust::model::AssetId;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let asset_id = AssetId::from_string("8bt2MZjuUCJPmfucPfaZPTXqrxmoCHCC8gVnbjZ7bhH6").unwrap();
let asset_details = node.get_asset_details(&asset_id).await.unwrap();
println!("{:?}", asset_details);
}
Sourcepub async fn get_assets_details(
&self,
asset_ids: &[AssetId],
) -> Result<Vec<AssetDetails>>
pub async fn get_assets_details( &self, asset_ids: &[AssetId], ) -> Result<Vec<AssetDetails>>
Get detailed information about given assets
use waves_rust::api::{Node, Profile};
use waves_rust::model::AssetId;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let asset_id1 = AssetId::from_string("8bt2MZjuUCJPmfucPfaZPTXqrxmoCHCC8gVnbjZ7bhH6").unwrap();
let asset_id2 = AssetId::from_string("973uk5Fbg5eLF8cZg2b2iKsVSoHepdJXRtCuhWcM6MsR").unwrap();
let assets_details = node.get_assets_details(&[asset_id1, asset_id2]).await.unwrap();
println!("{:?}", assets_details);
}
Sourcepub async fn get_nft(
&self,
address: &Address,
limit: u16,
after: Option<AssetId>,
) -> Result<Vec<AssetDetails>>
pub async fn get_nft( &self, address: &Address, limit: u16, after: Option<AssetId>, ) -> Result<Vec<AssetDetails>>
Get a list of non-fungible tokens at a given address. Max for 1000 tokens. For pagination, use the parameter {after}
use waves_rust::api::{Node, Profile};
use waves_rust::model::{AssetId, Address};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::MAINNET);
let address = Address::from_string("3PAETTtuW7aSiyKtn9GuML3RgtV1xdq1mQW").unwrap();
let after = AssetId::from_string("13PtvhAC28kNXXJP3Evgcba5mNMsCAQECUqCPBu5wJou").unwrap();
let nfts = node.get_nft(&address, 10, Some(after)).await.unwrap();
println!("{:?}", nfts);
}
Sourcepub async fn get_blockchain_rewards(&self) -> Result<BlockchainRewards>
pub async fn get_blockchain_rewards(&self) -> Result<BlockchainRewards>
Get current status of block reward
use waves_rust::api::{Node, Profile};
use waves_rust::model::{AssetId, Address};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let rewards = node.get_blockchain_rewards().await.unwrap();
println!("{:?}", rewards);
}
Sourcepub async fn get_blockchain_rewards_at_height(
&self,
height: u32,
) -> Result<BlockchainRewards>
pub async fn get_blockchain_rewards_at_height( &self, height: u32, ) -> Result<BlockchainRewards>
Get status of block reward at height
use waves_rust::api::{Node, Profile};
use waves_rust::model::{AssetId, Address};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let current_height = node.get_height().await.unwrap();
let rewards = node.get_blockchain_rewards_at_height(current_height - 10).await.unwrap();
println!("{:?}", rewards);
}
Sourcepub async fn get_height(&self) -> Result<u32>
pub async fn get_height(&self) -> Result<u32>
Get the current blockchain height
use waves_rust::api::{Node, Profile};
use waves_rust::model::{AssetId, Address};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let current_height = node.get_height().await.unwrap();
println!("{:?}", current_height);
}
Sourcepub async fn get_block_height_by_id(
&self,
block_id: &Base58String,
) -> Result<u32>
pub async fn get_block_height_by_id( &self, block_id: &Base58String, ) -> Result<u32>
Get the height of a block by its ID
use waves_rust::api::{Node, Profile};
use waves_rust::model::{AssetId, Address, Base58String};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let block_id = Base58String::from_string("oReBHRjMcUKqZxH6iVhthxQ72QndBFtfLHngV8aGW9y").unwrap();
let height = node.get_block_height_by_id(&block_id).await.unwrap();
println!("{:?}", height);
}
Sourcepub async fn get_block_height_by_timestamp(&self, timestamp: u64) -> Result<u32>
pub async fn get_block_height_by_timestamp(&self, timestamp: u64) -> Result<u32>
Get height of the most recent block such that its timestamp does not exceed the given {timestamp}
use waves_rust::api::{Node, Profile};
use waves_rust::model::{AssetId, Address};
use waves_rust::util::get_current_epoch_millis;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let now = get_current_epoch_millis();
let height = node.get_block_height_by_timestamp(now - 10_000).await.unwrap();
println!("{:?}", height);
}
Sourcepub async fn get_blocks_delay(
&self,
start_block_id: &Base58String,
block_num: u32,
) -> Result<u32>
pub async fn get_blocks_delay( &self, start_block_id: &Base58String, block_num: u32, ) -> Result<u32>
Average delay in milliseconds between last {block_num} blocks starting from block with {start_block_id}}
use waves_rust::api::{Node, Profile};
use waves_rust::model::Base58String;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let block_id = Base58String::from_string("oReBHRjMcUKqZxH6iVhthxQ72QndBFtfLHngV8aGW9y").unwrap();
let blocks_delay = node.get_blocks_delay(&block_id, 10).await.unwrap();
println!("{:?}", blocks_delay);
}
Sourcepub async fn get_block_headers_at_height(
&self,
height: u32,
) -> Result<BlockHeaders>
pub async fn get_block_headers_at_height( &self, height: u32, ) -> Result<BlockHeaders>
Get height of the most recent block such that its timestamp does not exceed the given {timestamp}
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let height = node.get_height().await.unwrap();
let block_headers = node.get_block_headers_at_height(height).await.unwrap();
println!("{:?}", block_headers);
}
Sourcepub async fn get_block_headers_by_id(
&self,
block_id: &Base58String,
) -> Result<BlockHeaders>
pub async fn get_block_headers_by_id( &self, block_id: &Base58String, ) -> Result<BlockHeaders>
Get headers of a given block
use waves_rust::api::{Node, Profile};
use waves_rust::model::Base58String;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let block_id = Base58String::from_string("oReBHRjMcUKqZxH6iVhthxQ72QndBFtfLHngV8aGW9y").unwrap();
let block_headers = node.get_block_headers_by_id(&block_id).await.unwrap();
println!("{:?}", block_headers);
}
Sourcepub async fn get_blocks_headers_seq(
&self,
from_height: u32,
to_height: u32,
) -> Result<Vec<BlockHeaders>>
pub async fn get_blocks_headers_seq( &self, from_height: u32, to_height: u32, ) -> Result<Vec<BlockHeaders>>
Get block headers at a given range of heights. Max range {from_height}-{to_height} is 100 blocks
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let to_height = node.get_height().await.unwrap();
let from_height = to_height.clone() - 5;
let block_headers = node.get_blocks_headers_seq(from_height, to_height).await.unwrap();
println!("{:?}", block_headers);
}
Sourcepub async fn get_last_block_headers(&self) -> Result<BlockHeaders>
pub async fn get_last_block_headers(&self) -> Result<BlockHeaders>
Get headers of the block at the current blockchain height
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let block_headers = node.get_last_block_headers().await.unwrap();
println!("{:?}", block_headers);
}
Sourcepub async fn get_block_at_height(&self, height: u32) -> Result<Block>
pub async fn get_block_at_height(&self, height: u32) -> Result<Block>
Get a block at a given height
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let current_height = node.get_height().await.unwrap();
let block = node.get_block_at_height(current_height).await.unwrap();
println!("{:?}", block);
}
Sourcepub async fn get_block_by_id(&self, block_id: &Base58String) -> Result<Block>
pub async fn get_block_by_id(&self, block_id: &Base58String) -> Result<Block>
Get a block by its ID
use waves_rust::api::{Node, Profile};
use waves_rust::model::Base58String;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let block_id = Base58String::from_string("oReBHRjMcUKqZxH6iVhthxQ72QndBFtfLHngV8aGW9y").unwrap();
let block = node.get_block_by_id(&block_id).await.unwrap();
println!("{:?}", block);
}
Sourcepub async fn get_blocks(
&self,
from_height: u32,
to_height: u32,
) -> Result<Vec<Block>>
pub async fn get_blocks( &self, from_height: u32, to_height: u32, ) -> Result<Vec<Block>>
Get blocks at a given range of heights. Max range is 100 blocks
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let to_height = node.get_height().await.unwrap();
let from_height = to_height.clone() - 5;
let blocks = node.get_blocks(from_height, to_height).await.unwrap();
println!("{:?}", blocks);
}
Sourcepub async fn get_last_block(&self) -> Result<Block>
pub async fn get_last_block(&self) -> Result<Block>
Get the block at the current blockchain height
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let block = node.get_last_block().await.unwrap();
println!("{:?}", block);
}
Sourcepub async fn get_blocks_by_generator(
&self,
generator: &Address,
from_height: u32,
to_height: u32,
) -> Result<Vec<Block>>
pub async fn get_blocks_by_generator( &self, generator: &Address, from_height: u32, to_height: u32, ) -> Result<Vec<Block>>
Get a list of blocks forged by a given address. Max range is 100 blocks
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let generator = Address::from_string("3Mxv6Dpa1qRuyQBRFg3GwUaf3rcjHqWwNmC").unwrap();
let to_height = node.get_height().await.unwrap();
let from_height = to_height.clone() - 5;
let blocks = node.get_blocks_by_generator(&generator, from_height, to_height).await.unwrap();
println!("{:?}", blocks);
}
Sourcepub async fn get_version(&self) -> Result<String>
pub async fn get_version(&self) -> Result<String>
Get Waves node version
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let version = node.get_version().await.unwrap();
println!("{:?}", version);
}
Sourcepub async fn get_balance_history(
&self,
address: &Address,
) -> Result<Vec<HistoryBalance>>
pub async fn get_balance_history( &self, address: &Address, ) -> Result<Vec<HistoryBalance>>
Get history of the regular balance at a given address
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mxv6Dpa1qRuyQBRFg3GwUaf3rcjHqWwNmC").unwrap();
let history = node.get_balance_history(&address).await.unwrap();
println!("{:?}", history);
}
Sourcepub async fn validate_transaction(
&self,
signed_tx: &SignedTransaction,
) -> Result<Validation>
pub async fn validate_transaction( &self, signed_tx: &SignedTransaction, ) -> Result<Validation>
Validates a transaction and measures time spent in milliseconds
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address,Amount, Base58String, ChainId, Transaction, TransactionData,
TransferTransaction, PrivateKey};
use waves_rust::util::{Crypto, get_current_epoch_millis};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let private_key = PrivateKey::from_seed(&Crypto::get_random_seed_phrase(12), 0).unwrap();
let signed_tx = Transaction::new(
TransactionData::Transfer(TransferTransaction::new(
Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q")?,
Amount::new(100, None),
Base58String::empty(),
)),
Amount::new(100000, None),
get_current_epoch_millis(),
private_key.public_key(),
3,
ChainId::TESTNET.byte(),
)
.sign(&private_key).unwrap();
let validation = node.validate_transaction(&signed_tx).await.unwrap();
println!("{:?}", validation);
}
Sourcepub async fn get_active_leases(
&self,
address: &Address,
) -> Result<Vec<LeaseInfo>>
pub async fn get_active_leases( &self, address: &Address, ) -> Result<Vec<LeaseInfo>>
Get all active leases involving a given address
use waves_rust::api::{Node, Profile};
use waves_rust::model::Address;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mxv6Dpa1qRuyQBRFg3GwUaf3rcjHqWwNmC").unwrap();
let active_leases = node.get_active_leases(&address).await.unwrap();
println!("{:?}", active_leases);
}
Sourcepub async fn get_lease_info(&self, lease_id: &Id) -> Result<LeaseInfo>
pub async fn get_lease_info(&self, lease_id: &Id) -> Result<LeaseInfo>
Get lease parameters by lease ID
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address, Id};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let lease_id = Id::from_string("BiJR8gCxR7crGEdy31jLkYpjpLy98kq3NuxPE8Z2Uk3b").unwrap();
let lease_info = node.get_lease_info(&lease_id).await.unwrap();
println!("{:?}", lease_info);
}
Sourcepub async fn get_leases_info(&self, lease_ids: &[Id]) -> Result<Vec<LeaseInfo>>
pub async fn get_leases_info(&self, lease_ids: &[Id]) -> Result<Vec<LeaseInfo>>
Get lease parameters by lease IDs
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address, Id};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let lease_id = Id::from_string("BiJR8gCxR7crGEdy31jLkYpjpLy98kq3NuxPE8Z2Uk3b").unwrap();
let leases_info = node.get_leases_info(&[lease_id]).await.unwrap();
println!("{:?}", leases_info);
}
Sourcepub async fn calculate_transaction_fee(
&self,
transaction: &SignedTransaction,
) -> Result<Amount>
pub async fn calculate_transaction_fee( &self, transaction: &SignedTransaction, ) -> Result<Amount>
Get the minimum fee for a given transaction
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address,Amount, Base58String, ChainId, Transaction, TransactionData,
TransferTransaction, PrivateKey};
use waves_rust::util::{Crypto, get_current_epoch_millis};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let private_key = PrivateKey::from_seed(&Crypto::get_random_seed_phrase(12), 0).unwrap();
let signed_tx = Transaction::new(
TransactionData::Transfer(TransferTransaction::new(
Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q")?,
Amount::new(100, None),
Base58String::empty(),
)),
Amount::new(100000, None),
get_current_epoch_millis(),
private_key.public_key(),
3,
ChainId::TESTNET.byte(),
)
.sign(&private_key).unwrap();
let fee = node.calculate_transaction_fee(&signed_tx).await.unwrap();
println!("{:?}", fee);
}
Sourcepub async fn broadcast(
&self,
signed_tx: &SignedTransaction,
) -> Result<SignedTransaction>
pub async fn broadcast( &self, signed_tx: &SignedTransaction, ) -> Result<SignedTransaction>
Broadcast a signed transaction.
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address,Amount, Base58String, ChainId, Transaction, TransactionData,
TransferTransaction, PrivateKey};
use waves_rust::util::{Crypto, get_current_epoch_millis};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let private_key = PrivateKey::from_seed(&Crypto::get_random_seed_phrase(12), 0).unwrap();
let signed_tx = Transaction::new(
TransactionData::Transfer(TransferTransaction::new(
Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q")?,
Amount::new(100, None),
Base58String::empty(),
)),
Amount::new(100000, None),
get_current_epoch_millis(),
private_key.public_key(),
3,
ChainId::TESTNET.byte(),
)
.sign(&private_key).unwrap();
node.broadcast(&signed_tx).await.unwrap();
}
Sourcepub async fn get_transaction_info(
&self,
transaction_id: &Id,
) -> Result<TransactionInfoResponse>
pub async fn get_transaction_info( &self, transaction_id: &Id, ) -> Result<TransactionInfoResponse>
Get a transaction by its ID
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address, Id};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let tx_id = Id::from_string("3kuZKAeyjcqavmezy86sWCAeXrgt3HBKa4HA8CZdT8nH").unwrap();
let tx_info = node.get_transaction_info(&tx_id).await.unwrap();
println!("{:?}", tx_info);
}
Sourcepub async fn get_transactions_by_address(
&self,
address: &Address,
limit: u16,
after_tx_id: Option<Id>,
) -> Result<Vec<TransactionInfoResponse>>
pub async fn get_transactions_by_address( &self, address: &Address, limit: u16, after_tx_id: Option<Id>, ) -> Result<Vec<TransactionInfoResponse>>
Get a list of the latest transactions involving a given address. For pagination, use the parameter {after_tx_id}
use waves_rust::api::{Node, Profile};
use waves_rust::model::{Address, Id};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let address = Address::from_string("3Mq3pueXcAgLcuWvJzJ4ndRHfqYgjUZvL7q").unwrap();
let after_id = Some(Id::from_string(
"3p6ffM2uyseFWPRQUcXMpr3gBKkKgt7jVQ8iDGQhVpRa",
).unwrap());
let txs_info = node.get_transactions_by_address(&address, 10, after_id).await.unwrap();
println!("{:?}", txs_info);
}
Sourcepub async fn get_transaction_status(
&self,
transaction_id: &Id,
) -> Result<TransactionStatus>
pub async fn get_transaction_status( &self, transaction_id: &Id, ) -> Result<TransactionStatus>
Get transaction status by its ID
use waves_rust::api::{Node, Profile};
use waves_rust::model::Id;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let id = Id::from_string("3p6ffM2uyseFWPRQUcXMpr3gBKkKgt7jVQ8iDGQhVpRa").unwrap();
let tx_status = node.get_transaction_status(&id).await.unwrap();
println!("{:?}", tx_status);
}
Sourcepub async fn get_transactions_statuses(
&self,
transaction_ids: &[Id],
) -> Result<Vec<TransactionStatus>>
pub async fn get_transactions_statuses( &self, transaction_ids: &[Id], ) -> Result<Vec<TransactionStatus>>
Get transaction statuses by their ID
use waves_rust::api::{Node, Profile};
use waves_rust::model::Id;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let id = Id::from_string("3p6ffM2uyseFWPRQUcXMpr3gBKkKgt7jVQ8iDGQhVpRa").unwrap();
let txs_statuses = node.get_transactions_statuses(&[id]).await.unwrap();
println!("{:?}", txs_statuses);
}
Sourcepub async fn get_unconfirmed_transaction(
&self,
transaction_id: &Id,
) -> Result<SignedTransaction>
pub async fn get_unconfirmed_transaction( &self, transaction_id: &Id, ) -> Result<SignedTransaction>
Get an unconfirmed transaction by its ID
use waves_rust::api::{Node, Profile};
use waves_rust::model::Id;
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let id = Id::from_string("3p6ffM2uyseFWPRQUcXMpr3gBKkKgt7jVQ8iDGQhVpRa").unwrap();
let unconfirmed_tx = node.get_unconfirmed_transaction(&id).await.unwrap();
println!("{:?}", unconfirmed_tx);
}
Sourcepub async fn get_unconfirmed_transactions(
&self,
) -> Result<Vec<SignedTransaction>>
pub async fn get_unconfirmed_transactions( &self, ) -> Result<Vec<SignedTransaction>>
Get a list of transactions in node’s UTX pool
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let unconfirmed_txs = node.get_unconfirmed_transactions().await.unwrap();
println!("{:?}", unconfirmed_txs);
}
Sourcepub async fn get_utx_size(&self) -> Result<u32>
pub async fn get_utx_size(&self) -> Result<u32>
Get the number of transactions in the UTX pool
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let utx_size = node.get_utx_size().await.unwrap();
println!("{:?}", utx_size);
}
Sourcepub async fn compile_script(
&self,
source: &str,
enable_compaction: bool,
) -> Result<ScriptInfo>
pub async fn compile_script( &self, source: &str, enable_compaction: bool, ) -> Result<ScriptInfo>
Compiles string code to base64 script representation
use waves_rust::api::{Node, Profile};
#[tokio::main]
async fn main() {
let node = Node::from_profile(Profile::TESTNET);
let script = "{-# CONTENT_TYPE EXPRESSION #-} sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)";
let compiled_script = node.compile_script(script, true).await.unwrap();
println!("{:?}", compiled_script);
}
Sourcepub async fn evaluate_script(
&self,
address: &Address,
expr: &str,
) -> Result<EvaluateScriptResponse>
pub async fn evaluate_script( &self, address: &Address, expr: &str, ) -> Result<EvaluateScriptResponse>
Evaluate script with given expression and get result
pub async fn wait_for_transaction( &self, id: &Id, polling_interval: Duration, timeout: Duration, ) -> Result<()>
Auto Trait Implementations§
impl Freeze for Node
impl !RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl !UnwindSafe for Node
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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request