forked from iotaledger/wallet.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
03_get_funds.rs
33 lines (23 loc) · 953 Bytes
/
03_get_funds.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! cargo run --example get_funds --release
// In this example we request funds from the faucet to our address
// Rename `.env.example` to `.env` first
use std::env;
use dotenv::dotenv;
use iota_client::request_funds_from_faucet;
use iota_wallet::{account_manager::AccountManager, Result};
#[tokio::main]
async fn main() -> Result<()> {
// This example uses dotenv, which is not safe for use in production
dotenv().ok();
// Create the account manager
let manager = AccountManager::builder().finish().await?;
// Get the account we generated with `01_create_wallet`
let account = manager.get_account("Alice").await?;
let address = account.addresses().await?;
let faucet_response =
request_funds_from_faucet(&env::var("FAUCET_URL").unwrap(), &address[0].address().to_bech32()).await?;
println!("{}", faucet_response);
Ok(())
}