Page cover image

Quickstart

The eckoDEX SDK is a stand-alone library designed to assist developers when interacting with the protocol in any environment that can execute JavaScript, such as websites or node scripts. With the SDK, you can manipulate data that has been queried from the Kadena Chainweb blockchain using libraries that assist with several needs, such as protection from rounding errors.

Good to know: The Kadena Chainweb blockchain uses a unique runtime environment which uses the Pact programming language to describe and execute smart contracts. Pact provides several benefits over an EVM/Solidity environment, but it does require a few concepts in order to work with effectively. This SDK does wrap some common errors and edge cases, however please keep in mind that expertise with Kadena Chainweb and/or Pact may be required to support your use case. For more about Kadena, see https://kadena.io/. To learn about the Pact runtime, you can refer to the full documentation: https://pact-language.readthedocs.io/en/stable/pact-reference.html

Install the library

You can install kaddex-sdk using any npm package manager.

# Install via NPM
npm install --save kaddex-sdk

Make your first request

To make your first request, send a signed Kadena chainweb transaction `to the swap smart contract using the KaddexSdk library function, swapExactIn. You will need to have some tokens in your account.

Take a look at how you might call this method using our official library:

import { KaddexSdk, retrieveVerifiedAccount, TOKENS } from 'kaddex-sdk';

const PUBLIC_KEY = '<YOUR PUBLIC KEY>'
const SECRET_KEY = '<YOUR SECRET KEY>'

// if your account name is different from your PUBLIC_KEY, use the correct value here
const account = await retrieveVerifiedAccount({ accountName: PUBLIC_KEY });

const kaddex = new KaddexSdk({ account, secretKey: SECRET_KEY });

try {
  (async () => {
    const swapResponse = await kaddex.swapExactIn({
      token0: {
        token: TOKENS.KDA,
        amount: 0.02
      },
      token1: {
        token: TOKENS.ABC,
        amount: 0.1
      },
      slippage: '0.05'
    });
    console.log(swapResponse);
  })();
} catch (err) {
  console.error(err);
}

Last updated