Skip to main content

Getting Started with Rust

Safe Password Storage

In a production setup, do not store passwords in the host's environment variables or in the source code. See our backup and security recommendations for production setups.

Install the IOTA SDK

Requirements

The IOTA SDK requires Rust and Cargo. You can find installation instructions in the Rust documentation.

We recommend that you update the Rust compiler to the latest stable version first:

rustup update stable

Dependencies

You must also install cmake, clang, pkg-config and openssl. You may need to install additional build tools on your system to run the build process successfully using Cargo.

You can install cmake, clang, and openssl with your distro's package manager or download them from their websites. On Debian and Ubuntu, you will also need the build-essential and libudev-dev packages.

Install the SDK Using Cargo

To start using the IOTA SDK in your Rust project, you can include it as a dependencies in your project's Cargo.toml by running:

cargo add iota-sdk

Build the SDK from Source

  1. Download the repository to any directory you choose:

    git clone https://github.com/iotaledger/iota-sdk
  2. Move to the base directory:

    cd iota-sdk/
  3. Build the SDK by running the following:

    cargo build

Usage

Client

To use the Client module, you simply need to create a Client.

sdk/examples/client/getting_started.rs
loading...

Wallet

To use the Wallet module, you need to create a Wallet. For this example to work features = ["stronghold"] is needed in the Cargo.toml import. To persist the wallet in a database, "rocksdb" can be added.

sdk/examples/wallet/getting_started.rs
loading...

What's next?

How-To Guides

Once you have installed the IOTA SDK, you can start building your application. You can find usage examples in this Wiki's how-to guides.

More Examples

You can use the provided code examples to get acquainted with the IOTA SDK. You can use the following command to run any example:

cargo run --release --all-features --example example_name
  • Where example_name is the name from the Cargo.toml name from the example folder. For example:
cargo run --release --all-features --example node_api_core_get_info

You can get a list of the available code examples with the following command:

cargo run --example

API Reference

The IOTA SDK Rust API Reference is in the crate documentation.