-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathget_funds.rs
36 lines (27 loc) · 1.06 KB
/
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
34
35
36
// Copyright 2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! cargo run --example get_funds --release
use iota_client::{secret::SecretManager, utils::request_funds_from_faucet, Client, Result};
#[tokio::main]
async fn main() -> Result<()> {
// This example uses dotenv, which is not safe for use in production
dotenv::dotenv().ok();
let node_url = std::env::var("NODE_URL").unwrap();
let faucet_url = std::env::var("FAUCET_URL").unwrap();
// Create a client instance
let client = Client::builder()
.with_node(&node_url)? // Insert the node here
.finish()?;
let secret_manager =
SecretManager::try_from_mnemonic(&std::env::var("NON_SECURE_USE_OF_DEVELOPMENT_MNEMONIC_1").unwrap())?;
let addresses = client
.get_addresses(&secret_manager)
.with_account_index(0)
.with_range(0..1)
.finish()
.await?;
println!("{}", addresses[0]);
let faucet_response = request_funds_from_faucet(&faucet_url, &addresses[0]).await?;
println!("{faucet_response}");
Ok(())
}