@liqwid2021/liqwid-sdk
v1.0.0-alpha.5
Published
A JavaScript SDK for the Liqwid Protocol
Downloads
2
Readme
Liqwid SDK
A JavaScript SDK for Ethereum and the Liqwid Protocol. Wraps around Ethers.js. Works in the web browser and Node.js.
This SDK is in open beta, and is constantly under development.
Liqwid Protocol
Simple methods for using the Liqwid protocol.
const liqwid = new Liqwid(window.ethereum) // in a web browser
// Ethers.js overrides are an optional 3rd parameter for `supply`
const trxOptions = { gasLimit: 250000, mantissa: false }
(async function() {
console.log('Supplying ADA to the Liqwid protocol...')
const trx = await liqwid.supply(Liqwid.ADA, 1)
console.log('Ethers.js transaction object', trx, trxOptions)
})().catch(console.error)
Install / Import
Web Browser
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/@liqwid2021/liqwid-sdk@latest/dist/browser/liqwid.min.js"></script>
<script type="text/javascript">
window.Liqwid; // or `Liqwid`
</script>
Node.js
npm install @liqwid2021/liqwid-sdk
const Liqwid = require('@liqwid2021/liqwid-sdk');
// or, when using ES6
import Liqwid from '@liqwid2021/liqwid-sdk';
Instance Creation
The following are valid Ethereum providers for initialization of the SDK.
new Liqwid(window.ethereum)
new Liqwid('http://127.0.0.1:8545')
new Liqwid()
new Liqwid('rinkeby')
// Init with private key (server side)
new Liqwid('https://rinkeby.infura.io/v3/_your_project_id_', {
privateKey: '0x_your_private_key_', // preferably with environment variable
});
// Init with HD mnemonic (server side)
new Liqwid('rinkeby', {
mnemonic: 'clutch captain shoe...', // preferably with environment variable
})
Constants and Contract Addresses
Names of contracts, their addresses, ABIs, token decimals, and more can be found in src/constants.ts
.
Addresses, for all networks, can be easily fetched using the getAddress
function, combined with contract name constants.
console.log(Liqwid.LQ, Liqwid.qLQ, Liqwid.ADA, Liqwid.qADA)
// LQ, qLQ, ADA, qADA
const address = Liqwid.util.getAddress(Liqwid.ADA);
Build for Node.js & Web Browser
git clone [email protected]:liqwid/liqwid-sdk.git
cd liqwid-sdk
nvm use
yarn install
yarn build
Web Browser Build
<!-- Local build (do `npm install` first) -->
<script type="text/javascript" src="./dist/browser/liqwid.min.js"></script>
<!-- Public NPM -> jsdeliver build -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@liqwid2021/liqwid-sdk@latest/dist/browser/liqwid.min.js"></script>
Node.js Build
// Local build (do `npm install` first)
const Liqwid = require('./dist/nodejs/index.js')
// Public NPM build
const Liqwid = require('@liqwid2021/liqwid-sdk')