https://github.com/vaimee/desmo-sdk
https://github.com/vaimee/desmo-sdk
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/vaimee/desmo-sdk
- Owner: vaimee
- License: mit
- Created: 2022-06-27T18:27:03.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-02T13:39:25.000Z (over 3 years ago)
- Last Synced: 2025-11-05T17:12:34.895Z (9 months ago)
- Language: TypeScript
- Size: 56.8 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README

**Overview**
> [DESMO-LD](https://github.com/vaimee/desmo/tree/c763cec12f6c9060a9f1a3335ff4cff60ece3df2) 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
## Features
The Desmo-SDK provides an easy way to interact with the contracts defined in [desmo-contracts](https://github.com/vaimee/desmo-contracts).
The Desmo-SDK provides functions to:
- Sign in your wallet with MetaMask or with a RPC provider
- Interact with the [Desmo-Hub](https://github.com/vaimee/desmo-contracts/blob/main/contracts/DesmoHub.sol) and [Desmo](https://github.com/vaimee/desmo-contracts/blob/main/contracts/DesmoHub.sol) 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
```ts
// 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
```ts
// 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
```ts
// 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](https://github.com/vaimee/desmo-front) that make use of the Desmo-SDK
## Documentation
Our code is well documented, if you have any doubt you can check our [documentation page](docs/modules.html)
## Acknowledgments

DESMO-SDK is founded by the [DESMO-LD project](https://ontochain.ngi.eu/content/desmo-ld) inside the [ONTOCHAIN](https://ontochain.ngi.eu/) european organization part of the [Next Generation Internet](https://www.ngi.eu/) fund.
## Contact
[VAIMEE](vaimee.com) - [@MaVaimee](https://twitter.com/MaVaimee) - [info@vaimee.com](mailto://info@vaimee.com)