Getting Started with Rust
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.
- Linux
- macOS
- Windows
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.
You can install cmake
and openssl
with Homebrew
:
brew install cmake openssl@1.1
You can download cmake
from the official website. You can install openssl
with vcpkg or chocolatey.
- vcpkg
- chocolatey
./vcpkg.exe install openssl:x64-windows
./vcpkg.exe integrate install
# You may want to add this to the system environment variables since you'll need it to compile the crate
set VCPKGRS_DYNAMIC=1
choco install openssl
# You may need to set the OPENSSL_DIR environment variable
set OPENSSL_DIR="C:\Program Files\OpenSSL-Win64"
Install the SDK Using Cargo
- Cargo add
- Cargo.toml
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
To start using the IOTA SDK in your Rust project, you can include the following line under dependencies
in your Cargo.toml
:
[dependencies]
iota-sdk = "1.0.0"
Build the SDK from Source
Download the repository to any directory you choose:
git clone https://github.com/iotaledger/iota-sdk
Move to the base directory:
cd iota-sdk/
Build the SDK by running the following:
cargo build
Usage
Client
To use the Client module, you simply need to create a Client
.
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.
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.