The IOTA distributed ledger works similarly to the other blockchains available through the Blockchain Integration Hub because it offers public immutable records to be created using EVRYTHNG actions and property updates.

However, it uses a different kind of chain, the Tangle. Instead of a new transaction being appended to the previous one, it's added to one in a nonlinear acyclic graph. A transaction is validated when two or more follow-up transactions are processed and added after it.

Another useful additional feature is that transactions can be linked in a Masked Authenticated Messaging (MAM) channel, allowing a reference to one transaction to read all linked transactions. This analogy to a Thng's action history (and by extension to a product's supply chain journey) makes it a good fit for this type of data.


How It Works

The integration with IOTA offered by EVRYTHNG works similarly to other connectors by sending data to IOTA (a SHA256 hash) each time an action is created. For example, each time an item has been produced or shipped as part of a supply chain. This data is persisted on the IOTA network and can later verify that the EVRYTHNG action wasn't changed or tampered with between its moment of creation and the moment a consumer accesses it.

An example use case where this is useful is for product provenance or authenticity experiences. By reading the actions from EVRYTHNG for a given Thng and comparing them to the hashes from IOTA, this data integrity can be proven and strengthen consumer trust in the brand building the experience.


Setting Up

The reactor-iota packaged script is offered for this purpose to simplify using the integration with no additional code writing or configuration required. As with other connectors, it's installed in a project application and triggered when a project-scoped action is created with the appropriate custom field.

Project and Application

If you haven't already done so, sign up (or log in) to the EVRYTHNG Dashboard. Choose an existing project (or create one), and then note the project's ID. This is used later to correctly scope the actions that are sent to IOTA.

Choose an existing application within that project (or create one), and find the Reactor section. Paste the contents of main.js into the main script area, and be sure to also copy the dependencies from package.json to the dependencies area (click Show dependencies to see this). Click Update to save the script.

1142

With the Reactor script in place, hashes of actions with the sendToIOTA: true custom field set (as specified by the Reactor filter are sent to IOTA. Actions that don't contain this custom field or aren't created in scope of the project are ignored.

Action Types

Be sure that the _sentToIOTA exists in the account and is scoped to the same application as the script. This is the action type used to create the receipt action (or confirmation action) after the response from IOTA has been received.

Last, choose one or more custom action types (such as _ItemShipped) that represent different supply chain events to be recorded within the IOTA network. As with the confirmation action type, these must also be scoped to the project selected earlier.

Thngs

Select an existing Thng, or create a new one, making sure it is scoped to the same project as the application housing the script. This Thng will be used to simulate the product item that is being moved along the supply chain and must have its actions sent to IOTA for authenticity purposes as described at the top of the page. Such a Thng can have any desired properties and structure as dictated by your use-case.

Make a note of the Thng's ID before continuing. This will be used in creating test actions with the Thng as their target.


Testing

To simulate the kind of action that would invoke the IOTA integration in a real-world scenario, it must contain the correct custom field as dictated by the script's Reactor filter. A simple example of such an action is shown below, demonstrating that other additional custom fields can also be included to suit the use-case:

{
  "type": "_ItemShipped",
  "thng": "U5de57ybeXsa9KRRaGypYsTf",
  "customFields": {
    "sendToIOTA": true,
    "orderNumber": "#4389",
    "shipment": "A87s-2"
  }
}

You can create this action through the API with an SDK or other tool, or using the 'Testing' section of the Dashboard as shown below:

934

After the action is created and the Reactor script has executed, the logs show details of the IOTA transaction being added and include the ID of the confirmation action.

987

The Thng has been updated to include all the information (iotaMamState) necessary to continue the MAM chain if another action is created on the same Thng (which is likely). The iotaRoot custom field contains the root transaction of the chain and can be used with a public Tangle explorer (example) to show that the data has been sent successfully.

1029

Proving Data Integrity

The main value unlocked with this method of replicating action data comes when another party is given access and allowed to verify the integrity of it. Usually, this is achieved in a web app designed for consumers through the following process:

  1. Identify the Thng to be authenticated. You normally do this using a QR code on pack, scanned with a library such as scanthng.js.
  2. Download the history of actions for that Thng, and perform a SHA256 hash on each. Each hash value is unique to the input data.
  3. Use the iotaRoot custom field on the Thng to fetch the pre-recorded hashes (from each Reactor script invocation) from the IOTA network.
  4. Check that every hash found in IOTA appears in the list of action hashes generated in step 2. If this is the case, the data in EVRYTHNG is verified as intact and unchanged since it was created by the manufacturer. If hashes are missing, some that don't agree, the Thng can't be identified, or the Thng has no action history, its authenticity is suspect.

This process is summarized in the diagram below:

511

Conclusion

Like the other available Blockchain Integration Hub connectors, the IOTA connector simplifies integrating into an existing solution or a completely new one. This allows EVRYTHNG action data to be propagated to the IOTA network to serve as a source of immutable, validated, and public data for use-cases requiring independent verifiable authenticity statements in a supply chain context.

You can find the IOTA integration Reactor script in the reactor-iota GitHub repository. Read more about how the IOTA decentralized network works in the IOTA documentation.