Expand description
The IOTA Rust SDK
It aims at providing a similar SDK functionality like the one existing for TypeScript. IOTA Rust SDK builds on top of the JSON RPC API and therefore many of the return types are the ones specified in iota_types.
The API is split in several parts corresponding to different functionalities as following:
- CoinReadApi - provides read-only functions to work with the coins
- EventApi - provides event related functions functions to
- GovernanceApi - provides functionality related to staking
- QuorumDriverApi - provides functionality to execute a transaction block and submit it to the fullnode(s)
- ReadApi - provides functions for retrieving data about different objects and transactions
- TransactionBuilder - provides functions for building transactions
§Usage
The main way to interact with the API is through the IotaClientBuilder, which returns an IotaClient object from which the user can access the various APIs.
§Getting Started
Add the Rust SDK to the project by running cargo add iota-sdk
in the root
folder of your Rust project.
The main building block for the Iota Rust SDK is the IotaClientBuilder, which provides a simple and straightforward way of connecting to an Iota network and having access to the different available APIs.
Below is a simple example which connects to a running Iota local network, devnet, and testnet. To successfully run this program, make sure to spin up a local network with a local validator, a fullnode, and a faucet server (see the README for more information).
use iota_sdk::IotaClientBuilder;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let iota = IotaClientBuilder::default()
.build("http://127.0.0.1:9000") // provide the Iota network URL
.await?;
println!("Iota local network version: {:?}", iota.api_version());
// local Iota network, same result as above except using the dedicated function
let iota_local = IotaClientBuilder::default().build_localnet().await?;
println!("Iota local network version: {:?}", iota_local.api_version());
// Iota devnet running at `https://fullnode.devnet.io:443`
let iota_devnet = IotaClientBuilder::default().build_devnet().await?;
println!("Iota devnet version: {:?}", iota_devnet.api_version());
// Iota testnet running at `https://testnet.devnet.io:443`
let iota_testnet = IotaClientBuilder::default().build_testnet().await?;
println!("Iota testnet version: {:?}", iota_testnet.api_version());
Ok(())
}
§Examples
For detailed examples, please check the APIs docs and the examples folder in the repository.
Re-exports§
pub use iota_json as json;
pub use iota_json_rpc_types as rpc_types;
pub use iota_types as types;
Modules§
Structs§
- Provides all the necessary abstractions for interacting with the Iota network.
- Builder for creating an IotaClient for connecting to the Iota network.