Before You Begin

In order to integrate the Veriscope SDK, there are a number of things to consider.

The Testnet is a Proof of Authority Network of Transaction (TXN) and Sealer Nodes. TXN nodes accept RPC and Websocket connections, whereas Sealer Nodes simply seal the new blocks into the chain.

When you are ready to integrate the SDK, you will be provided access to a TXN Node via RPC and WS.

Testnet Environment:

The Shyft Smart Contracts have been deployed to the Testnet and are available to receive requests via the Transaction nodes.

The work flow is of two types:

  • Making requests over HTTP to the TXN Node over RPC
  • Capturing blockchain events from the TXN Node over WS

Since the Smart Contracts are written in solidity and the Testnet POA network is Ethereum based, there are two node js libraries that make the workflow very easy to integrate the SDK, them being web3 and truffle.

The SDK discussed in the following sections utilizes these libraries among others, so some familiarity with them is ideal for integration.

Below is a diagram typical of an integration. Your existing platform may be Java, or PHP, or some other server side environment.

The SDK which leverages web3 and truffle is managed by a NodeJS server. Due to network activity and block times, most requests to the Testnet are performed with asynchronous functions. This is why it is ideal that requests from your server side platform are passed through to the node server and then on to the Testnet. When the Node Server receives the asynchronous response, it can pass over the response data to your server environment via an HTTP webhook.

alt text

For example:

As noted in the next sections, there is a requirement for the FATF solution to generate Shyft Accounts for users on your platform. Let’s walk through how that would work with the above diagram. First Java would make an HTTP request to Node to create an account by passing the user id as a parameter such as:

GET http://localhost:8080/ta-create-user?user_id=1

On node set up an endpoint using:

const express = require('express');
const app = express();
app.listen(8080, () => {
console.log('listening on 8080');
});
app.get('/ta-create-user', (req, res) => {
var user_id = req.param('user_id');
trustAnchorCreateUserAccount(user_id);
res.sendStatus(201);
});

When node receives the request, it passes the param to the function trustAnchorCreateUserAccount which handles the request to the TestNet.

function trustAnchorCreateUserAccount(user_id) {
var result = web3.eth.accounts.create();
var address = result['address'];
var privateKey = result['privateKey'];
var obj = { user_id: user_id, address: address, request: "ta-create-user", private_key: privateKey };
sendWebhookMessage(obj);
}

When the function receives a response from the TestNet, it packages the response as a JSON object and sends it to the webhook function sendWebhookMessage.

const axios = require('axios');
const webhook_url = 'http://localhost:8000/webhook';
function sendWebhookMessage(obj) {
axios.post(webhook_url, {
obj:obj
})
.then((res) => {
console.log(`statusCode: ${res.statusCode}`)
})
.catch((error) => {
console.error(error)
});
}

In your Java platform you will have a webhook url accepting webhook messages from node and persist the data in your database; ie this object:

{ user_id: user_id, address: address, request: "ta-create-user", private_key: privateKey }

By noting the response by the originating url request ‘ta-create-user’, you will know what was the original request and store the data appropriately.

Example for capturing events from the TestNet:

Similar to the setup above, subscribing to TestNet events utilizes the same libraries, however no HTTP request is needed from Java as shown in the diagram below.

alt text

In the Node server, you can set up an event subscriber as follows:

function setupTrustStorageManagerListeners() {
(async () => {
tas = await TrustAnchorStorage.deployed();
tas.EVT_setAttestation().on('data', (event) => {
console.log('EVT_setAttestation');
sendWebhookMessage(event);
}).on('error', function(error){
console.log(error);
});
console.log("setupTrustStorageManagerListeners EVT_setAttestation success");
})();
}
setupTrustStorageManagerListeners();

Note: You would run this script in a separate process on your server. When the event “EVT_setAttestation” is emitted from the TestNet, this service will capture the event message and simply pass the event object to the sendWebhookMessage function as described above, which in turn sends the event to your Java environment over the webhook url.

We hope this brief document helps in understanding what is needed to integrate the Veriscope SDK.

In summary, your integration team should be familiar with running a node server, some nodejs libraries like web3, subscribing to sockets and passing data objects (JSON) to a webhook in your exchange environment.

In terms of security, ensure your node server is behind your firewall and your webhook only accepts connections from your node server.

If you have any questions or comments, feel free to contact us.

We hope this guide makes it easy for you to follow along as you integrate Veriscope and solve the FATF Travel Rule.

Next sections outline all the SDK functions you need to run for full FATF requirements.