Typed wrapper built around the OriginTrail DKG.js SDK. Learn more about what DKG is and how to use it for your own applications by reading the official docs.
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)
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);
});
// 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:
install the dev3-sdk package ( npm install dev3-sdk )
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