#iota #tangle #client

iota-client

The official, general-purpose IOTA client library in Rust for interaction with the IOTA network (Tangle)

21 releases (5 stable)

2.0.1-rc.7 Mar 9, 2023
2.0.1-rc.5 Dec 21, 2022
2.0.1-rc.4 Nov 22, 2022
1.4.0 Mar 28, 2023
0.2.0 Jun 24, 2019

#880 in Magic Beans

Download history 49/week @ 2024-02-16 106/week @ 2024-02-23 60/week @ 2024-03-01 19/week @ 2024-03-08 38/week @ 2024-03-15

242 downloads per month
Used in 3 crates (2 directly)

Apache-2.0

1MB
23K SLoC

Rust 20K SLoC // 0.1% comments Java 3K SLoC // 0.2% comments Batch 68 SLoC

Contains (JAR file, 60KB) gradle-wrapper.jar

Warning Deprecated - The client has been moved to https://github.com/iotaledger/iota-sdk

iota.rs (iota-client)

The official, general-purpose IOTA client library in Rust for interaction with the IOTA network (Tangle).

The goal of this library is to have one source code of truth, which means that there is one implementation in Rust and bindings to other programming languages.

For value transfers we recommend using wallet.rs.

This library allows you to do the following:

  • Create blocks with tagged data and transaction payloads
  • Get blocks and outputs
  • Sign transactions
  • Generate addresses
  • Interact with an IOTA node

Using the library

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

rustup update stable

The nightly Rust compiler should be fine but some changes might not be compatible.

Also for Linux libudev is needed for the ledger_nano feature and can be installed with apt install libudev-dev.

Add iota-client as a dependency in Cargo.toml:

[dependencies]
iota-client = "2.0.1-rc.6"

Or, for the latest changes:

[dependencies]
iota-client = { git = "https://github.com/iotaledger/iota.rs", branch = "develop" }

Then, use the library in code with:

// Note that the hyphen is replaced with an underscore
use iota_client;

Limitations

  • When using the mqtt feature, connecting to a MQTT broker using raw IP doesn't work with TCP. This is a limitation of rustls.

Examples

You can see examples using the library in the examples directory. Try them with:

# cargo run --example <name of the example without .rs>
cargo run --example node_api_core_get_info

For examples where a seed is required (e.g. 01_generate_addresses) you need to create a .env file under the current directory. You can do so by renaming .env.example to .env.

API reference

You can read the API reference here, or generate it yourself.

If you'd like to explore the implementation in more depth, the following command generates docs for the whole crate, including private modules:

cargo doc --document-private-items --no-deps --open

Bindings

Bindings to other programming languages are available under the folder bindings.

Joining the discussion

If you want to get involved in the community, need help with setting up, have any issues or just want to discuss IOTA with other people, feel free to join our Discord in the #client-libs channel.

License

The Apache 2.0 license can be found here.


lib.rs:

A general purpose IOTA client library for interaction with the IOTA network (Tangle)

High-level functions are accessible via the Client.

Sending a block without a payload

let client = Client::builder()
  .with_node("http://localhost:14265")?
  .finish()?;

let block = client
  .block()
  .finish()
  .await?;

println!("Block sent {}", block.id());

Dependencies

~12–53MB
~827K SLoC