NAV

Introduction

Welcome to Dedoco Trust Engine API Specifications for Developers!

This document contains the API specifications for integration with the Dedoco Trust Engine.

Version History

Date Version Content
10 May 2023 1.0.0 Initial Release

Whitepaper

Unable to display PDF file. Download instead.

A. API Developer Account

To have access to our Trust Engine API, please provide the following information and submit your application request to delab@dedoco.com.

Name of Organization:
Business Address:
Business Country:
Business Website URL:

Contact Person (Full Name):
Contact Person (Email):
Contact Person (Mobile):

Application Name:
Application Description/Use Case:
Application Type: [ Internal Use | Public SaaS | Enterprise App | Development | Testing | Others ]
Application URL:

After your application has been reviewed and approved, you will receive an email containing the API key for accessing the Trust Engine API.

B. Quickstart

Get a listing of all available contracts

curl -XGET 'https://dte.dedoco.com/v1/contracts' \
        -H 'Authorization: Bearer <api_key>'

Create a namespace

curl -XPOST 'https://dte.dedoco.com/v1/namespaces' \
         -H 'Authorization: Bearer <api_key>' \
         -H 'Content-Type: application/json' \
         -d '{
                "chain": "mumbai",
                "name": "test/v1"
                "type": "process/v2"
            }'

Create a process

curl -XPOST 'https://dte.dedoco.com/v1/processes' \
         -H 'Authorization: Bearer <api_key>' \
         -H 'Content-Type: application/json' \
         -d '{
              "contract": "test/v1",
              "publicMeta": {
                "k1": "v1"
              },
              "privateMeta": {
                "k2": "v2"
              }
            }'

Sign the process

curl -XPOST 'https://dte.dedoco.com/v1/processes/${processId}/events' \
         -H 'Authorization Bearer <api_key>' \
         -H 'Content-Type: application/json' \
         -d '{
              "contract": "test/v1",
              "publicMeta": {
                "k3": "v3"
              },
              "privateMeta": {
                "k4": "v4"
              }
            }'

Query

curl -XGET 'https://dte.dedoco.com/v1/processes/${processId}' \
        -H 'Authorization Bearer <api_key>'
curl -XGET 'https://dte.dedoco.com/v1/query/process?process.k1=v1' \
        -H 'Authorization Bearer <api_key>'
curl -XGET 'https://dte.dedoco.com/v1/query/process?signature.k3=v3' \
        -H 'Authorization Bearer <api_key>'`
  1. Request for an API key from delab@dedoco.com.
  2. Use the API key as Bearer Auth in subsequent requests.
  3. Apply the sample code on the right hand side of this page.

C. Environments

Stage

Base URL

https://dte.stage.dedoco.com/v1

Prod

Base URL

https://dte.dedoco.com/v1

D. Concepts

The Trust Engine is a web2 >> web3 on-ramp for data-centric blockchain applications. The intention is to provide a simple web2 API that "just works" without the developer needing to think too much about web3 implications like contract management and indexing.

Here are some of the important concepts to understand.

Namespace

A namespace is a data container attached to a specific smart contract.

When you perform API actions as this namespace, it will talk to that smart contract.

The contract you register on the namespace will determine what capabilities the namespace has. If you register your namespace as an audit/v1 contract, you will not be able to create processes.

Contracts

You only need to think about contracts when you register a namespace.

A contract type is an upgrade path for a number of contracts. For example, you can have the process contract type that can upgrade between process/v1, process/v2, etc.

E. Processes

The Process APIs are designed to model multi-stage business processes.

A Process is a document attached to a series of signatures. It can help you track all changes to a particular document.

You create a Process with an initial documentHash. From this initial hash, you use the sign APIs to transition to other hashes.

The process as well as each of the signatures can have either public or private metadata attached.

F. Authentication

Use API key as bearer token

-H 'Authorization: Bearer <api_key>'

For now, authentication is dead simple.

  1. Request an API key from delab@dedoco.com.
  2. You get the API key.
  3. Pass in the API key as a bearer token for your API calls.

G. Contract APIs

Endpoint: Create Namespace

POST /namespaces
Create or upgrade a data namespace backed by a contract.

Authorization:
Bearer <api_key>

Content-Type:
application/json

Sample request:

curl -XPOST 'https://dte.dedoco.com/v1/namespaces' \
         -H 'Authorization: Bearer <api_key>' \
         -H 'Content-Type: application/json' \
         -d '{
              "chain": "mumbai",
              "name": "test/v1"
              "contract": "process/v2"
            }'

Parameters:

Parameter Type Description Required/Optional
chain string "hedera:test" OR "mumbai" OR the name of a custom network. Required
name string The name of the namespace. This is how you will refer to it in future calls. Required
contract string The contract you want to deploy for this namespace. See v1/contracts for options. Required

Sample response:

{
  "address": "0x...."
}

Responses:

Code Description
200 { address }
400 [contract.dne] Specified contract does not exist.
400 [network.conflicting] A namespace cannot be changed to a different chain.
400 [contract.conflicting] Contract upgrades must happen along a set path. You cannot upgrade an audit contract to a process contract.

Endpoint: Add User to Namespace

POST /namespaces/users
Add a user to a namespace.

Authorization:
Bearer <api_key>

Content-Type:
application/json

Parameters:

Parameter Type Description Required/Optional
user string The username of the user. Required
permission string read write

Responses:

Code Description
200 User is successfully added to namespace.

Endpoint: Get Namespaces

GET /namespaces
Get a listing of available namespaces.

Authorization:
Bearer <api_key>

Content-Type:
application/json

Sample request:

curl -XPOST 'https://dte.dedoco.com/v1/namespaces' \
         -H 'Authorization: Bearer <api_key>'

Parameters:

No parameters.

Sample response:

{
  namespaces: [
    {
      "name": "test/v1",
      "chain": "mumbai",
      "type": "process/v2",
      "address": "0x..."
    }
    ...
  ]
}

Responses:

Code Description
200 Namespaces have been successfully retrieved.

Endpoint: Get Contracts

GET /contracts
Get a listing of available contracts.

Authorization:
Bearer <api_key>

Content-Type:
application/json

Sample request:

curl -XPOST 'https://dte.dedoco.com/v1/contracts' \
         -H 'Authorization: Bearer <api_key>'

Parameters:

No parameters.

Sample response:

{
  results: [
    {
      "type": "process"
      "versions": [
        {"key": "process/v1"},
        {"key": "process/v2"}
      ]
    }
    ...
  ]
}

Responses:

Code Description
200 Contracts have been successfully retrieved.

Endpoint: Create Custom Network

GET /networks
Create a custom network.

Authorization:
Bearer <api_key>

Content-Type:
application/json

Parameters:

Parameter Type Description Required/Optional
name string The name of the network. Required
url string The URL of the network JSON RPC endpoint. Required
privateKey string The private key used for the network. Required

Responses:

Code Description
200 Network is successfully created.

H. Process APIs

The process APIs refer to process/* contracts.

Endpoint: Create Process

POST /processes
Create a new process.

Authorization:
Bearer <api_key>

Content-Type:
application/json

Sample request:

curl -XPOST 'https://dte.dedoco.com/v1/processes' \
         -H 'Authorization: Bearer <api_key>' \
         -H 'Content-Type: application/json' \
         -d '{
              "namespace": "test/v1",
              "publicMeta": {
                "k1": "v1"
              },
              "privateMeta": {
                "k2": "v2"
              }
            }'

Parameters:

Parameter Type Description Required/Optional
namespace string The namespace name (as created in POST /namespaces). Required
publicMeta object Metadata to be stored on the blockchain.

BE CAREFUL. This data is stored to the blockchain. Do not use this to store sensitive information.
Optional
privateMeta object Metadata to be stored in the Trust Engine database. Optional

Sample response:

{
  "id": "5f....",
  "transactionHash": "0x..."
}

Responses:

Code Description
200 { id, transactionHash }
400 [namespace.dne] Specified namespaces does not exist.
400 [namespace.invalid] The specified namespace does not support process creation.
400 [hash.invalid] documentHash is not a valid hash.

Endpoint: Add User to Process

POST /processes/{processId}/users
Add a user to a process.

Authorization:
Bearer <api_key>

Content-Type:
application/json

Parameters:

Parameter Type Description Required/Optional
signer string The username of the user. Required
permission string read write

Responses:

Code Description
200 User is successfully added to process.

Endpoint: Add Event to Process

POST /processes/{processId}/events
Add a signature to a process.

Authorization:
Bearer <api_key>

Content-Type:
application/json

Sample request:

curl -XPOST 'https://dte.dedoco.com/v1/processes/{processId}/events' \
         -H 'Authorization: Bearer <api_key>' \
         -H 'Content-Type: application/json' \
         -d '{
              "publicMeta": {
                "k3": "v3"
              },
              "privateMeta": {
                "k4": "v4"
              }
            }'

Parameters:

Parameter Type Description Required/Optional
publicMeta object Metadata to be stored on the blockchain.

BE CAREFUL. This data is stored to the blockchain. Do not use this to store sensitive information.
Optional
privateMeta object Metadata to be stored in the Trust Engine database. Optional

Sample response:

{
  "transactionHash": "0x..."
}

Responses:

Code Description
200 { transactionHash }
404 [process.dne] Process does not exist.
400 [feature.unsupported] A feature (publicMeta, signature field, etc.) in the request is not supported by the specified namespace.

Endpoint: Get Process

GET /processes/{processId}
Get a process.

Authorization:
Bearer <api_key>

Content-Type:
application/json

Parameters:

No parameters.

Responses:

Code Description
200 Process has been successfully retrieved.

I. Query APIs

Endpoint: Query Process

GET /query/process
Query processes either by event or process metadata

Authorization:
Bearer <api_key>

Content-Type:
application/json

Sample request - query by event metadata:

curl -XGET 'https://dte.dedoco.com/v1/query/process?event.k3=v3' \
        -H 'Authorization: Bearer <api_key>'

Sample request - query by process metadata:

curl -XGET 'https://dte.dedoco.com/v1/query/process?process.k2=v2' \
        -H 'Authorization: Bearer <api_key>'

Query Parameters:

Parameter Type Description Required/Optional
process.{key} string The value corresponding to the key (as passed to POST /processes through publicMeta or privateMeta parameters). Optional
event.{key} string The value corresponding to the key (as passed in POST /processes/{processId}/events through publicMeta or privateMeta parameters). Optional

Sample response:

{
  processes: [
    {
      "id": "361bf3f495a84e7eb5d597b4e4cf3ebb",
      "namespace": {
        "name": "test/v1",
        "chain": "mumbai",
        "type": "process/v2"
      },
      # hash of transaction process was created
      "transactionHash": "0x332e5f69c96d21fdececa851761bb507e449888c687b7927672e67ce7f6ab583",
      # initial hash
      "documentHash": "0x125",
      "publicMeta": {
        "name": "test2"
      },
      "privateMeta": {
        "nric": "123124"
      },
      # or 'complete' depending on if it has been successfully indexed by Graph Protocol
      "status": "pending",
      "signatures": [
        {
          "transactionHash": "0xb0328d360d814540a54666f4958d10197d30cc583884a88983077eaa279d8174",
          "publicMeta": {
            "name": "test3",
            "description": "testing signatures"
          },
          "privateMeta": {
            "email": "jvrch@dedoco.com"
          },
          "fromHash": "0x125",
          "toHash": "0x126",
          "status": "pending"
        }
      ]
    }
    ...
  ]
}

Responses:

Code Description
200 Processes have been successfully retrieved.