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>

source

pub fn from_url(url: &'a str) -> Self

Create an Node from url string.

Examples found in repository?
examples/get_node_version.rs (line 5)
4
5
6
7
8
9
10
11
12
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(())
}
More examples
Hide additional examples
examples/get_address_by_alias.rs (line 5)
4
5
6
7
8
9
10
11
12
13
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let node = Node::from_url(MAINNET_URL);

    // Assemble all the puzzles
    let result = node.get_address_by_alias("vlzhr").await?;

    println!("vlzhr -> {}", result.address());

    Ok(())
}
examples/get_leasing_info.rs (line 5)
4
5
6
7
8
9
10
11
12
13
14
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(())
}
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(())
}
source

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

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

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(())
}
Examples found in repository?
examples/get_address_by_alias.rs (line 8)
4
5
6
7
8
9
10
11
12
13
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let node = Node::from_url(MAINNET_URL);

    // Assemble all the puzzles
    let result = node.get_address_by_alias("vlzhr").await?;

    println!("vlzhr -> {}", result.address());

    Ok(())
}
source

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

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

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

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

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(())
}
Examples found in repository?
examples/get_leasing_info.rs (line 8)
4
5
6
7
8
9
10
11
12
13
14
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(())
}
source

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(())
}
Examples found in repository?
examples/get_node_version.rs (line 7)
4
5
6
7
8
9
10
11
12
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(())
}
source

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

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§

source§

impl<'a> Default for Node<'a>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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.

§

impl<T> Instrument for T

§

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

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

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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