JavaScript SDK for Nolus, written in TypeScript.
- client - Nolus Client service
- wallet - Nolus Wallet service (Coin, Chain, Wallet, etc.)
- contracts - Interact with the Nolus Protocol
- utils - Utils (Currency, Keys, etc.)
- constants - Nolus network constants
yarn add @nolus/nolusjs
OR
npm install @nolus/nolusjs
Set up Nolus client:
NolusClient.setInstance(tendermintRpc);
Create and set up wallet:
const mnemonic = KeyUtils.generateMnemonic();
const accountNumbers = [0];
const path = accountNumbers.map(makeCosmoshubPath)[0];
const privateKey = await KeyUtils.getPrivateKeyFromMnemonic(mnemonic, path);
// Set up wallet
const offlineSigner = await DirectSecp256k1Wallet.fromKey(
privateKey,
ChainConstants.BECH32_PREFIX_ACC_ADDR,
);
const nolusWallet = await nolusOfflineSigner(offlineSigner);
nolusWallet.useAccount();
Set up instance:
NolusClient.setInstance(tendermintRpc);
const cosm = await NolusClient.getInstance().getCosmWasmClient();
oracleInstance = new NolusContracts.Oracle(cosm, oracleContractAddress);
leaserInstance = new NolusContracts.Leaser(cosm, leaserContractAddress);
leaseInstance = new NolusContracts.Lease(cosm, leaseContractAddress);
lppInstance = new NolusContracts.Lpp(cosm, lppContractAddress);
treasuryInstance = new NolusContracts.Treasury(cosm, treasuryContractAddress);
Nolus Protocol interacting:
Lease Quote:
await leaserInstance.leaseQuote(
'1000', // downpaymentAmount
'unls' // downpaymentCurrencyTicker
'OSMO' // wantedLeaseCurrency
);
Open Lease:
// fee structure example
const fee = {
gas: '1000000',
amount: [
{
amount: '50000',
denom: ChainConstants.COIN_MINIMAL_DENOM;,
},
],
};
const downpaymentCurrencyToIbc = AssetUtils.makeIBCMinimalDenom('OSMO');
await leaserInstance.openLease(
borrowerWallet,
'OSMO' // wantedLeaseCurrency
fee,
[{ denom: downpaymentCurrencyToIbc, amount: '1000' }],
);
Get Leaser contract config:
await leaserInstance.getConfig();
Import and use directly:
ChainConstants.COIN_TYPE;
const privateKey = await KeyUtils.getPrivateKeyFromMnemonic(mnemonic, path);
The auto-generated API documentation - Requires basic TypeScript understanding.
See DEVELOPMENT.md.
Nolus.js uses CosmJS.