LogoLogo
eckoDAOeckoDEXeckoWalleteckoGOV
  • 👾Welcome
    • eckoDAO - Introduction
    • Product Suite
    • $KDX Tokenomics
      • $KDX Token Distribution
      • $KDX Liquidity Mining
    • Governance
  • 🔄eckoDEX
    • Introduction
    • eckoDEX Litepaper
      • Why eckoDEX?
        • Problems in DeFi
        • Solution: Long Term Scalability
        • Solution: Gas-free
        • Solution: Slippage Control
        • Solution: Decentralised Infrastructure
        • Solution: Secure Smart Contracts
      • Industry Outlook
        • DEX Market Potential
        • eckoDEX: The Next Generation of DEXes
      • Vision
    • Platform
    • How to Swap
      • X-Swap
      • The eckoDEX Wrapper
    • Migrate liquidity from eckoDEX Beta to Mainnet V1
    • How to Add Liquidity
      • Single-Sided Liquidity
      • Understanding Liquidity Provision and Impermanent Loss
    • Governance Mining
      • Understanding Governance Mining
  • 💰eckoWALLET
    • Introduction
    • eckoWALLET API
    • Quicksign: KIP-0015
    • WalletConnect
    • FAQ
  • 🏛️eckoGOV
    • 👋Welcome to eckoGOV
      • 📚Litepaper Overview
    • 🚀Getting Started
      • 📋Minimum Requirements
      • 📥Login
      • 🌍Spaces
        • 💰Spaces Treasury
      • 👥Members
        • 🔠Edit Profile
    • 🧑‍🏫Role System
      • 1️L1 - eckoMEMBER
      • 2️L2 - eckoLEAD
      • 3️L3 - eckoCORE
      • 🧮Voting Power
      • 🙋Applying for a eckoDAO Role
      • 🔎KYC
    • 🌀Proposal Epoch
      • 🗃️Proposal Categories
      • 📑Creating Proposals
        • 🧾Proposal Template
        • 👍Proposal Example
      • 📊Voting on Proposals
      • 🗣️Discourse - Proposal Discussion
    • 💰Using the KDX Treasury
    • 📄Smart Contracts
  • 🔒Security & Contracts
    • Bug Bounty
    • Audits
  • 🤝Marketing
    • Social & Communities
    • eckoDAO Brand Assets
    • eckoWALLET Brand Assets
  • ⚡SDK
    • Overview
    • Quickstart
    • Reference
      • eckoDEX SDK
        • createPair
        • addLiquidity
        • removeLiquidity
        • swap
        • swapExactIn
        • swapExactOut
      • retrieveVerifiedAccount
      • TOKENS
Powered by GitBook
On this page
  • Install the library
  • Make your first request
  1. SDK

Quickstart

PreviousOverviewNextReference

Last updated 11 months ago

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 . To learn about the Pact runtime, you can refer to the full documentation:

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);
}
https://kadena.io/
https://pact-language.readthedocs.io/en/stable/pact-reference.html
⚡
Page cover image