Skip to main content

Request Funds

Once you have created your account, you can start using for value transactions. Since these examples target the testnet, you can request funds using the request_funds_from_faucet function.

Online Faucet

You can request test funds from the Shimmer Testnet Faucet.

Code Example

The following example will:

  1. Create an account manager.
  2. Get Alice's account which was created in the first guide.
  3. Retrieve an address related to Alice's account.
  4. Request funds to the FAUCET_URL you defined in the .env file.

This example uses dotenv, which is not safe for use in production environments.

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

async fn main() -> Result<()> {
// This example uses dotenv, which is not safe for use in production

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


Run the Example

Run the example by running the following command:

cargo run --example get_funds --release

Expected Output

"address": "tst1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jax7rgxyj",
"waitingRequests": 1