The IOTA distributed ledger works in a similar way to the other blockchains available through the Blockchain Integration Hub in that 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 is added to one in a nonlinear acyclic graph. A transaction is validated when two or more subsequent transactions are processed and added after it.

Another useful additional feature is that transactions can be linked together in a MAM (Masked Authenticated Messaging) channel, allowing a reference to one transaction to be used 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 in a similar way 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 be used to verify that the EVRYTHNG action was not modified 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 to the hashes from IOTA, this data integrity can be proven and so strengthen consumer trust in the brand building the experience.

Setting Up

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

### Project and Application

If you have not already done so, sign up (or log in) to the EVRYTHNG Dashboard. Once signed in, choose an existing project (or create a new one), then make a note of the project's ID. This will be used later to correctly scope the actions that will be sent to IOTA.

Choose an existing application within that project (or create a new one), and locate the 'Reactor' section. Paste the contents of main.js into the main script area, and make 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.


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

Action Types

Make 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) once the response from IOTA has been received.

Lastly, choose one or more custom action types (such as _ItemShipped) that will 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.


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 It Out

To simulate the kind of action that would invoke the IOTA integration in a real-world scenario, it needs only to 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 for the example:


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


At the same time, the Thng will have been updated to include all the information (iotaMamState) necessary to continue the MAM chain in the event that another action is created on the same Thng (which is quite likely in a real world situation). 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.


Proving Data Integrity

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

  1. Identify the Thng to be authenticated. This is normally done 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 then the data in EVRYTHNG is verified as intact and unchanged since it was created by the manufacturer. If there are hashes missing, some that do not agree, the Thng can't be identified, or the Thng has no action history at all, then its authenticity is suspect!

This process is summarised in the diagram below:



Like the other available Blockchain Integration Hub connectors, the IOTA connector makes it easy to integrate 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 decentralised network works in the IOTA documentation.