Running Instadapp SDK

These instructions are for running the SDK

To get started, install the DSA SDK package from NPM:

npm install dsa-sdk

For browsers, via jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/dsa-sdk@latest/build/dsa.min.js"></script>

For production, we recommend linking to a specific version number (jsdeliver)

Usage

To enable web3 calls via SDK, instantiate web3 library

// in browser
if (window.ethereum) {
  window.web3 = new Web3(window.ethereum)
} else if (window.web3) {
  window.web3 = new Web3(window.web3.currentProvider)
} else {
  window.web3 = new Web3(customProvider)
}

// in nodejs
const Web3 = require('web3')
const DSA = require('dsa-sdk');
const web3 = new Web3(new Web3.providers.HttpProvider(ETH_NODE_URL))

Now instantiate DSA with web3 instance

// in browser
const dsa = new DSA(web3);

// in nodejs
const dsa = new DSA({
  web3: web3,
  mode: "node",
  privateKey: PRIVATE_KEY
});

That's it. You're all set to start using the SDK methods.

Last updated