Struct waves_rust::api::Node

source ·
pub struct Node { /* private fields */ }

Implementations§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Evaluate script with given expression and get result

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Wrap the input message T in a tonic::Request
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more