OriginTrail

Similar to the Chainpoint blockchain integration, EVRYTHNG offers an integration with OriginTrail in order to add secure and trackable information about EVRYTHNG actions on the public blockchain.

This works through the reactor-origintrail Reactor script. Reactor scripts allow developers to run custom scripts in response to common Platform events, such as when an action is created. In this case, we use a script that sends action data to the OriginTrail API for writing to the blockchain, and then store details about the resulting transaction in a new certification action.

This page walks you through implementing this integration in your account. See the Reactor walkthrough for more information about how the Reactor feature works within the Platform.


Setting up an Account

If you don't already have an EVRYTHNG account, create one now. Once you are logged in, choose an existing project, or create one (called 'OriginTrail Project' for example) by clicking Create project at the top of the left navigation.

398

After the project has been created or chosen, go to the project's Applications page and create an Application (called OriginTrail Integrator for example) by clicking Add new in the top toolbar.

509

You're now ready to install the OriginTrail Reactor script that powers the integration.


Installing the Script

The application houses the Reactor script that sends action data to the OriginTrail API whenever a specific kind of action is created. This script is available from the reactor-origintrail GitHub repository and is written to be easily added to any EVRYTHNG project with only minimal configuration.

Navigate to the application's details page (select its parent project first, if required), and locate the Reactor section. If Reactor isn't enabled for your account, contact us.

Copy the contents of main.js from the repository into the main script space on the left. Copy the dependencies of the package.json into the dependencies section of the page (you might have to click Show dependencies first).

1186

Specify a value for OT_AUTH_TOKEN at the top of the script. This is the authorization token for the OriginTrail node in use (EVRYTHNG offer nodes for our customers to use, available upon request). Without this token, the integration won't work.


Setting up Actions

The integration uses EVRYTHNG actions to send and receive data from the Reactor script (and OriginTrail, by extension). An action of one kind starts the script, and another holds the output after the transaction is added to the blockchain.

To set up these actions, go to the Action Types page of the Dashboard while the correct project is selected in the navigation. Create two action types:

  • A type representing a typical event that requires blockchain validation, such as _Manufactured.
  • The action type specified in the script as the OUTPUT_ACTION_TYPE that contains the transaction result. The default used here is _originTrailCertified.
875

Finally, create a Thng or product that provides the target for the action. In this scenario, the _Manufactured action represents a record of the event indicating that the item was created.


Testing It Out

To simulate the entire scenario, create an action of the first action type (such as _Manufactured) on the Thng or product created or selected earlier. As you can see from the script's onActionCreated() filter comment, the action must contain the createOriginTrail: true item in its customFields to trigger the script. For example:

{
  "type": "_Manufactured",
  "thng": "U5de57ybeXsa9KRRaGypYsTf",
  "customFields": {
    "createOriginTrail": true
  }
}

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

927

After the action has been created, go back to the application's details page and look at the Reactor Logs tab to see details of the interaction with OriginTrail:

916

You can also go to the Actions page of the Dashboard to see the _originTrailCertified action created by the Reactor script after receiving the transaction confirmation from OriginTrail:

850

Conclusion

Now that the integration is set up, all actions that are created in the scope of the chosen project with custom fields trigger the Reactor script and have their information recorded in the blockchain through OriginTrail.

This provides another layer of proof for the events in the supply chain that the actions represent, which can build partner and consumer trust in use-cases such as product provenance and authenticity.