Welcome to Dev3
  • ➕Create a Dev3 App
  • 🤖SDK
    • 📖Introduction
    • ⚙️Initialization
    • ➡️Importing Contracts
    • 🤝User Authentication
      • Options
    • 🔍Query Contracts
      • Function Parameters
    • ⚡Execute Contracts
      • Execution Options
    • 🛠️Deploy Contracts
      • Deployment Options
    • 📖Address Book
    • ❓FAQ
      • Out of gas error
  • INTEGRATIONS
    • 🔷Chainlink Feeds
    • 🔷Chainlink Subscriptions
      • 🎲VRF Subscriptions
      • 🧮Functions Subscriptions
      • 🤖Upkeep Subscriptions
    • 🎆OriginTrail DKG
    • 📽️OriginTrail DKG Video Tutorial
    • 📊Polyflow Analytics
  • Pricing
    • 💸Dev3 Pricing Plans
    • 💸Polyflow Pricing Plans
  • 🚀Guides
    • 👾Launching an NFT Collection
      • Step 1: Upload assets
      • Step 2: Upload metadata
      • Step 3: Deploy contracts
  • 🏫Resources
    • 👨‍💻Developer Resources
Powered by GitBook
On this page
  • Usage
  • Dev3 Widget Support
  • Quick App Prototyping
  1. INTEGRATIONS

OriginTrail DKG

PreviousUpkeep SubscriptionsNextOriginTrail DKG Video Tutorial

Last updated 1 year ago

Typed wrapper built around the . Learn more about what DKG is and how to use it for your own applications by reading the official .

Dev3 SDK exposes the wrapper for anyone to use and build on top of the OriginTrail DKG. Read below on how to start using the wrapper directly from the Dev3 SDK.

Requirements:

  • Installed Dev3 SDK inside the project

    • npm install dev3-sdk

  • OriginTrail Node connection (local, mainnet, or testnet)

  • Wallet funded with TRAC & NEURO tokens

Dev3 provides all its users with free to use OriginTrail node! Testnet Node running at . Mainnet Node running at . Reach out to our and receive test TRAC & NEURO tokens for free.

Usage

import { DkgClient } from "dev3-sdk";
 
const dkg = new DkgClient({
    endpoint: 'https://dkg-testnet.dev3.sh',  // gateway node URI
    port: 8900,
    blockchain: {
        name: 'otp::testnet',
        publicKey: "public-key",   // wallet must be funded with TRAC tokens and native coins
        privateKey: "private-key", // in order to execute state changing transactions
    }
});

If initialized properly, the DKG object can be used to interact with the OriginTrail DKG!

Fetching Node Info

dkg.node.info().then((result) => {
    console.log("Node info result: ", result);
});

Creating Asset

const publicAssertion = {
    '@context': 'https://schema.org',
    '@id': 'https://tesla.modelX/2321',
    '@type': 'Car',
    'name': 'Tesla Model X',
    'brand': {
        '@type': 'Brand',
        'name': 'Tesla'
    },
    'model': 'Model X',
    'manufacturer': {
        '@type': 'Organization',
        'name': 'Tesla, Inc.'
    },
    'fuelType': 'Electric',
    'numberOfDoors': 5,
    'vehicleEngine': {
        '@type': 'EngineSpecification',
        'engineType': 'Electric motor',
        'enginePower': {
            '@type': 'QuantitativeValue',
            'value': '416',
            'unitCode': 'BHP'
        }
    },
    'driveWheelConfiguration': 'AWD',
    'speed': {
        '@type': 'QuantitativeValue',
        'value': '250',
        'unitCode': 'KMH'
    },
}

// write operation example (using pub/priv key of an operational wallet which is funded with native coins and TRAC tokens)
dkg.asset.create(publicAssertion, { epochsNum: 2 }).then((result) => {
    console.log("Asset created. Result: ", result);
});

Fetching Asset

// taken  for example from asset creation response
const assetUal = "<assset-ual>";

// read operation example
dkg.asset.get(assetUal).then((result) => {
    console.log("Asset fetched. Result: ", result);
});

Dev3 Widget Support

Dev3 Widget now supports DKG interactions natively! This means that if you omit the private/public keypair from the SDK initialization object, DKG interactions will be processed by the Dev3 widget.

To activate Dev3 Widget support for the project, simply:

  1. install the dev3-sdk package ( npm install dev3-sdk )

  2. initialize the module inside your project:

import {Dev3SDK, DkgClient} from "dev3-sdk";

// Activate Dev3 Widget support
Dev3SDK.attach("dev3-workspace-api", "dev3-workspace-project-id"); // your Dev3 project data

window.DkgClient = new DkgClient({
    endpoint: 'http://otp-testnet.dev3.sh',  // gateway node URI
    port: 8900,
    blockchain: {
        name: 'otp::testnet',
        // publicKey: "", // operational wallet address
        // privateKey: "", // operational wallet priv key
    }
});

Quick App Prototyping

To start using the DKG and prototype your application, clone the Dev3 SDK repo and start working on our test project setup!

$ git clone https://github.com/0xdev3/dev3-sdk
$ cd dev3-sdk
$ npm install
$ npm run build
$ cd test/dkg-app
$ npm install
$ npm run build
$ npm start # starts the example dkg app at localhost:1234

The example repo GitHub link:

create the

🎆
OriginTrail DKG.js SDK
docs
http://dkg-testnet.dev3.sh
http://dkg-mainnet.dev3.sh
discord channel
Dev3 Workspace
https://github.com/0xDev3/dev3-sdk/tree/master/test/dkg-app
Dev3 Widget support.