Giter Site home page Giter Site logo

chen-michael / streams-gateway-core Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iot2tangle/streams-gateway-core

0.0 0.0 0.0 105 KB

The Core Component holding all the logic to send Data to the IOTA-Tangle over Streams

License: Apache License 2.0

Rust 100.00%

streams-gateway-core's Introduction

Streams-Gateway-Core

Introdution

This is the Core Repository for the iot2tangle Gateways. It provides the base API to open Channels and publish signed data to the Tangle.

To learn more about IOTA-Streams clicke here

To look at example implementations we have two Gateways, for HTTP and MQTT, already deployed with the Streams-Gateway-Core.

Usage

To interact with Library import it as a dependency by adding it to the Cargo.toml file:
gateway_core = { git = "https://github.com/iot2tangle/streams-gateway-core", branch="master"}

You can then import the library into your project with:
extern crate gateway_core;

API

To Create a new channel use:
Channel::new(node: String, send_opt: SendTrytesOptions, seed_option: Option<String>);

  • node is: the url of an IOTA Node
  • send_opt: are options used by the IOTA Client when sending Transaction
  • seed_option: Can be None to generate a new Seed or Some(seed) to use an existing seed

To Open the channel and get its address:
let address: String = channel.open().unwrap();
This will open the Channel by generating the channel address and publishing the signature keys
This address will be needed to read the data from the Tangle


To Send signed data over the Tangle by writing to the channel:
write_signed<T>(&mut self, data: T) -> Result<String>

  • The type T needs to have the serde::Serialize trait

If the transaction is succesfully sent the Identifier of the transaction will be returned.

Example

To run the provided example:
cargo run --example test
This will send a "Hello World" message to the Tangle!

Note

The Underlying libraries are not compatible for 32Bit Processors and Operating systems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.