Function sn_client::send

source ·
pub async fn send(
    from: HotWallet,
    amount: NanoTokens,
    to: MainPubkey,
    client: &Client,
    verify_store: bool
) -> Result<CashNote, Error>
Expand description

Use the client to send a CashNote from a local wallet to an address. This marks the spent CashNote as spent in the Network

§Arguments

  • from - HotWallet
  • amount - NanoTokens
  • to - MainPubkey
  • client - Client
  • verify_store - Boolean. Set to true for mandatory verification via a GET request through a Spend on the network.

§Example

use sn_client::{Client, WalletClient, Error};
use bls::SecretKey;
use sn_transfers::{HotWallet, MainSecretKey};
use tracing::error;
use sn_client::send;
use sn_transfers::Transfer;
let client = Client::new(SecretKey::random(), None, None, None).await?;
let mut first_wallet = HotWallet::load_from_path(&tmp_path,Some(MainSecretKey::new(SecretKey::random())))?;
let mut second_wallet = HotWallet::load_from_path(&tmp_path,Some(MainSecretKey::new(SecretKey::random())))?;
    let tokens = send(
        first_wallet, // From
        second_wallet.balance(), // To
        second_wallet.address(), // Amount
        &client, // Client
        true, // Verification
    ).await?;