1.3.0 • Published 1 year ago

@vaimee/desmold-sdk v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

DESMO-SDK

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.

Features

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

Installation

Starting using the Desmo-SDK is really easy, just use the following command in your Node.js project:

npm i @vaimee/desmold-sdk

Usage Examples

DesmoHub contract

Register your TDD

// 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);

Get your TDD

// 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();

Desmo Contract

Buy a query

// 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

Documentation

Our code is well documented, if you have any doubt you can check our documentation page

Acknowledgments

DESMO-LD

DESMO-SDK is founded by the DESMO-LD project inside the ONTOCHAIN european organization part of the Next Generation Internet fund.

Contact

VAIMEE - @MaVaimee - info@vaimee.com

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.3.0

1 year ago

1.2.1

2 years ago

1.2.9

1 year ago

1.2.10

1 year ago

1.2.11

1 year ago

1.0.0-alpha.17

2 years ago

1.0.0-alpha.16

2 years ago

1.0.0-alpha.15

2 years ago

1.0.0-alpha.13

2 years ago

1.0.0-alpha.14

2 years ago

1.0.0-alpha.12

2 years ago

1.0.0-alpha.11

2 years ago

1.0.0-alpha.10

2 years ago

1.0.0-alpha.9

2 years ago

1.0.0-alpha.8

2 years ago

1.0.0-alpha.7

2 years ago

1.0.0-alpha.6

2 years ago

1.0.0-alpha.5

2 years ago

1.0.0-alpha.4

2 years ago

1.0.0-alpha.3

2 years ago

1.0.0-alpha.2

2 years ago

1.0.0-alpha.1

2 years ago

1.0.0-alpha.0

2 years ago