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.

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

This page will walk you through the process of easily implementing this integration in your own account. See the Reactor walkthrough for more information on how the Reactor feature works within the Platform.


## Setting up an Account

If you do not already have an EVRYTHNG account, create one now. Once you are logged in, choose an existing project, or create a new one (called 'OriginTrail Project' for example) using the 'Create project' button at the top of the left-hand navigation:

398398

Once the project has been created or chosen, go to the project's 'Applications' page and create a new application (called 'OriginTrail Integrator' for example) with the 'Add new' button in the top toolbar:

509509

We are now ready to install the OriginTrail Reactor script that powers the integration.


Installing the Script

The application will house the Reactor script that will send 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 in such a way that it can be easily and simply added to any EVRYTHNG project with only minimal configuration.

Navigate to the application's details page (selecting the project it lives in first, if required), and locate the 'Reactor' section. If you do not have Reactor enabled for your account, please contact us.

Copy the contents of main.js from the repository into the main script space on the left of this section, and then copy the dependencies of the package.json into the dependencies section of the page (you may have to click 'Show dependencies' first).

11861186

At this point you should make sure to specify a value for OT_AUTH_TOKEN at the top of the script. This will be 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 will not work.


## Setting up Actions

The integration makes use of EVRYTHNG actions to send and receive data from the Reactor script (and OriginTrail, by extension). An action of one kind will start the script, and another will be the output once the transaction has been 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 that represents 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 that will be used here is _originTrailCertified.
875875

Finally, create a Thng or product that will be the target for the action. In this scenario, the _Manufactured action will represent a record of the event that the item was created.


Testing It Out

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

{
  "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:

927927

Once 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:

916916

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:

850850

## Conclusion

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

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