Overview
In the context of the DESMO-LD an important part of the project relay on storing The Thing Description Directories (TDDs) URLs on-chain so that they can be selected to provide the query result and increase its score, thus the DESMO-SDK is a tool that provides all the features required to interact with them.
The Desmo-SDK provides an easy way to interact with the contracts defined in desmo-contracts. The Desmo-SDK provides functions to:
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.
Generated using TypeDoc