Example 5

Rust adjustments for Example "Request Funds".

What adjustments do I need to make in Rust?

In summary, here are the steps you need to take to create the API function.


There is no need to add any crates. It's the same as in Example 3.

api.rs - Used Paths

Add the function iota_wallet::iota_client::request_funds_from_faucet:

use iota_wallet::{
    iota_client::request_funds_from_faucet, // <- Add this one
    secret::{stronghold::StrongholdSecretManager as WalletStrongholdSecretManager},
    secret::{SecretManager as WalletSecretManager}

api.rs - Function request_funds()

pub fn request_funds(network_info: NetworkInfo, wallet_info: WalletInfo) -> Result<String> {
    let rt = Runtime::new().unwrap();
    rt.block_on(async {
        let stronghold_filepath = wallet_info.stronghold_filepath;

        let faucet_url = network_info.faucet_url;

        // Use the function iota_wallet::iota_client::request_funds_from_faucet
        let faucet_response =
            request_funds_from_faucet(&faucet_url, &wallet_info.last_address).await?;


Checks using cargo build

All checks (-> except iOS Simulator) should work without any issue. Please also refer to the explanations of Example 3 and the corresponding video (2023-09-03: ToDo).

To examine the various targets, you should navigate from playground_app root directory to the rust directory:

cd rust

Then, within the rust directory, excute the following commands.


If you haven't already, install the cargo-ndk command using:

cargo install cargo-ndk

I only check the ABI arm64-v8a.

a) If you've had NO problems with the 3rd party library libsodium, use the command:

cargo ndk -t arm64-v8a build

b) If you've HAD problems with the 3rd party library libsodium, use the command:

SODIUM_LIB_DIR="/path/to/libsodium" SODIUM_SHARED=1 cargo ndk -t arm64-v8a build


SODIUM_LIB_DIR="/Users/yourname/playground_app/android/app/src/main/jniLibs/arm64-v8a" SODIUM_SHARED=1 cargo ndk -t arm64-v8a build

-> Why do you need SODIUM_LIB_DIR and SODIUM_SHARED here?


cargo build --target aarch64-apple-darwin

iOS Simulator

This check will fail, please refer to the explanations of Example 3 (Libsodium).

cargo build --target aarch64-apple-ios-sim

iOS Device

cargo build --target aarch64-apple-ios