Struct Node

Source
pub struct Node { /* private fields */ }

Implementations§

Source§

impl Node

Source

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);
}
Source

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);
}
Source

pub fn url(&self) -> Url

Source

pub fn chain_id(&self) -> u8

Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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, &regex).await.unwrap();
    println!("{:?}", account_data);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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();
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

pub async fn evaluate_script( &self, address: &Address, expr: &str, ) -> Result<EvaluateScriptResponse>

Evaluate script with given expression and get result

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,