Getting Started with Rust
The IOTA SDK is currently in alpha. APIs, interfaces, and behavior may change without notice between releases. It is not yet recommended for production use.
The IOTA Rust SDK is the core library for interacting with the IOTA network. It provides a native Rust interface for building high-performance applications, and serves as the foundation for all other language bindings.
Prerequisites
Before using the Rust SDK, ensure you have:
- Rust: Version 1.75 or higher (installed via rustup).
- Cargo: Included with the Rust toolchain.
Installation
- Crates.io (Recommended)
- Build from Source
- Cargo add
- Cargo.toml
cargo add iota-sdk@=3.0.0-alpha.1
Add the IOTA SDK to your Cargo.toml:
[dependencies]
iota-sdk = "=3.0.0-alpha.1"
If you need the latest unreleased features or want to contribute to the SDK, you can depend directly on the Git repository:
[dependencies]
iota-rust-sdk = { git = "https://github.com/iotaledger/iota-rust-sdk.git", branch = "develop" }
tokio = { version = "1", features = ["full"] }
Alternatively, clone the repository and build it locally:
git clone https://github.com/iotaledger/iota-rust-sdk.git
cd iota-rust-sdk
cargo build
For more details on the project structure and development setup, refer to the Rust SDK README in the repository.
Quick Start Example
The following example demonstrates how to connect to the IOTA Devnet and retrieve the Chain ID.
1. Create a new project
cargo new iota-quickstart
cd iota-quickstart
2. Install the SDK
Install the SDK as mentioned above and also add tokio as a dependency for asynchronous support.
3. Write src/main.rs
Replace the contents of src/main.rs with the following:
loading...
4. Run the code
cargo run
What's Next?
Now that you have connected to the network, you can explore more advanced features:
- Accounts & Wallets: Manage keypairs and derive IOTA addresses.
- Transactions: Build and sign Programmable Transaction Blocks (PTBs).
- Events: Subscribe to real-time on-chain events.
View more comprehensive examples in the official Rust examples directory.