iota-lib-rs 0.1.3

A rust implementation of the IOTA API
iota-lib-rs-0.1.3 doesn't have any documentation.

An unofficial implementation of the IOTA api in rust.

Build Status Windows Build status Version Documentation License

This library requires nightly rust until async becomes stable

This is a port of the IOTA Java/JS API into Rust. It works, but I wouldn't trust it with real money yet. Having said that, please let me know if you have any suggestions or run into any issues.

Here are some reasons you might want to use this library:

  1. It has a very fast implementation of local PoW (1-2s with MwM = 14, 4-6ms with MwM = 9 on my laptop)
  2. You'll benefit from Rust's very nice type system
  3. This library is more actively maintained than Jota
  4. Now that the library is working, I'm going to be obsessively going over it to improve safety, performance, and usability
  5. It would make me personally happy :)

Documentation

https://docs.rs/iota-lib-rs

This library currently requires nightly rust to build.

Things that are done:

  • Crypto
    • Curl
    • Kerl
    • PearlDiver
    • ISS
    • HMAC
    • Signing
  • Model
    • Bundle
    • Input
    • Inputs
    • Neighbor
    • Signature
    • Transaction
    • Transfer
  • Utils
    • Checksum
    • Constants
    • Converter
    • InputValidator
    • IotaAPIUtils
    • IotaUnitConversion
    • IotaUnits
    • Multisig
    • SeedRandomGenerator
    • StopWatch
    • TrytesConverter
  • API
    • IRI API calls and responses
      • add neighbors
      • attach_to_tangle
      • find_transactions
      • get_balances
      • broadcastTransactions
      • storeTransactions
      • get_inclusion_states
      • get_neighbors
      • get_node_info
      • get_tips
      • get_transactions_to_approve
      • get_trytes
      • remove_neighbor
      • were_addresses_spent_from
      • check_consistency
    • Ease of use wrappers/helpers
      • new_address
      • get_new_address
      • send_trytes
      • store_and_broadcast
      • get_inputs
      • prepare_transfers
      • traverse_bundle
      • send_transfer
      • get_bundle

Here's an example of how to send a transaction: (Note that we're using the address as the seed in send_transfer()...don't do this)

#![feature(futures_api)]
#![feature(async_await)]
#![feature(await_macro)]
extern crate iota_lib_rs;
extern crate futures;

use iota_lib_rs::iota_api;
use iota_lib_rs::options::SendTransferOptions;
use iota_lib_rs::utils::trytes_converter;
use iota_lib_rs::model::*;

use futures::executor::block_on;
use futures::executor::ThreadPool;
use futures::task::SpawnExt;

fn main() {
    let trytes = "HELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDD";
    let message = trytes_converter::to_trytes("Hello World").unwrap();
    let mut transfer = Transfer::default();
    *transfer.value_mut() = 0;
    *transfer.address_mut() = trytes.to_string();
    *transfer.message_mut() = message;
    let api = iota_api::API::new("https://pow3.iota.community");
    let options = SendTransferOptions{
        threads: None,
        inputs: None,
        reference: None,
        remainder_address: None,
        security: None,
        hmac_key: None,
    };
   // If you want to do this synchronously and block on the send_transfers call
   let mut tx = block_on(api.send_transfers(vec![transfer.clone()], trytes.to_string(), 3, 14, true, options.clone())).unwrap();
   println!("{:?}", tx);

   // Create thread pool
   let mut thread_pool = ThreadPool::new().expect("Failed to create threadpool");
   // Spawn async request on pool
   let h = thread_pool.spawn_with_handle(async move {
        await!(api.send_transfers(vec![transfer], trytes.to_string(), 3, 14, true, options)).unwrap()
   }).unwrap();
   // Wait for completion
   tx = thread_pool.run(h);

   println!("{:?}", tx);
}
}

Donations:

If you feel so inclined, you can find my address for donations at:

https://ecosystem.iota.org/projects/iota-lib-rs