This forked repository is used as a archive for the results of the ONTOCHAIN open call 2
Overview
DESMO-LD is a distributed oracle for IoT data. This project exposes a practical NodeJS and browser API to interact with DESMO-LD system components.
Table of Contents
The Desmo-SDK provides an easy way to interact with the contracts defined in desmo-contracts. The Desmo-SDK provides functions to:
- Sign in your wallet with MetaMask or with a RPC provider
- Interact with the Desmo-Hub and Desmo contracts :
- calling all the public function on the contracts
- retrieve the results with an event based approach
Starting using the Desmo-SDK is really easy, just use the following command in your Node.js project:
npm i @vaimee/desmold-sdk
// Sign in with a RPC provider and a private key
const walletSigner: WalletSignerJsonRpc = new WalletSignerJsonRpc(chainURL);
walletSigner.signInWithPrivateKey(privateKEY);
// Otherwise Sign in with MetaMask
// const walletSigner = new WalletSignerMetamask(window.ethereum);
const desmohub: DesmoHub = new DesmoHub(walletSigner);
// state changing methods work with an event based approach
await desmohub.startListeners();
desmoHub.tddCreated$.subscribe(() => console.log('tdd created'));
await desmoHub.registerTDD(TDDUrl);
// Sign in with a RPC provider and a private key
const walletSigner: WalletSignerJsonRpc = new WalletSignerJsonRpc(chainURL);
walletSigner.signInWithPrivateKey(privateKEY);
// Otherwise Sign in with MetaMask
// const walletSigner = new WalletSignerMetamask(window.ethereum);
const desmohub: DesmoHub = new DesmoHub(walletSigner);
// no need to listen for events -> not a state changing method
const myTDDObject = await desmohub.getTDD();
// Sign in with a RPC provider and a private key
const walletSigner: WalletSignerJsonRpc = new WalletSignerJsonRpc(chainURL);
walletSigner.signInWithPrivateKey(privateKEY);
// Otherwise Sign in with MetaMask
// const walletSigner = new WalletSignerMetamask(window.ethereum);
const desmohub: DesmoHub = new DesmoHub(walletSigner);
const desmoContract = new DesmoContract(walletSigner);
const eventPromise = firstValueFrom(desmoHub.requestID$);
await desmoHub.getNewRequestID();
const event = await eventPromise;
await desmoContract.buyQuery(
event.requestID,
JSON.stringify(query),
iExecDAppAddress,
);
For further usage examples we suggest to go check out our front-end that make use of the Desmo-SDK
Our code is well documented, if you have any doubt you can check our documentation page
DESMO-SDK is founded by the DESMO-LD project inside the ONTOCHAIN european organization part of the Next Generation Internet fund.