Kuknos
Creating equitable access to the global financial system

js-kuknos-sdk

js-kuknos-sdk is a Javascript library for communicating with a Kuknos Horizon server. It is used for building Kuknos apps either on Node.js or in the browser.

It provides:

  • a networking layer API for Horizon endpoints.
  • facilities for building and signing transactions, for communicating with a kuknos Horizon instance, and for submitting transactions or querying network history.

kuknos-sdk vs kuknos-base

kuknos-sdk is a high-level library that serves as client-side API for Horizon. kuknos-base is lower-level library for creating kuknos primitive constructs via XDR helpers and wrappers.

Most people will want instead of kuknos-base. You should only use kuknos-base if you know what you're doing!

If you add kuknos-sdk to a project, do not add kuknos-base! Mis-matching versions could cause weird, hard-to-find bugs. kuknos-sdk automatically installs kuknos-base and exposes all of its exports in case you need them.

Quick start

Using npm to include js-kuknos-sdk in your own project:

npm install js-kuknos-sdk
  • Install it using npm:
  • npm install js-kuknos-sdk
    1. require/import it in your JavaScript:
    var StellarSdk = require('kuknos-sdk');

    To self host for use in the browser

    1. Install it using bower:
    bower install kuknos-sdk
    1. Include it in the browser:
    <script src="./bower_components/kuknos-sdk/kuknos-sdk.js"></script>
    <script>
      console.log(StellarSdk);
    </script>

    To develop and test js-kuknos-sdk itself

    1. Clone the repo:
    git clone https://github.com/KuknosOrg/js-kuknos-sdk
    1. Install dependencies inside js-kuknos-sdk folder:
    cd js-kuknos-sdk
    npm install
    1. Install Node 10.16.3

    Because we support earlier versions of Node, please install and develop on Node 10.16.3 so you don't get surprised when your code works locally but breaks in CI.

    Here's out to install nvm if you haven't: https://github.com/creationix/nvm

    nvm install
    
    # if you've never installed 10.16.3 before you'll want to re-install yarn
    npm install -g yarn

    If you work on several projects that use different Node versions, you might it helpful to install this automatic version manager: https://github.com/wbyoung/avn

    1. Observe the project's code style

    While you're making changes, make sure to run the linter-watcher to catch any linting errors (in addition to making sure your text editor supports ESLint)

    node_modules/.bin/gulp watch
    `

    If you're working on a file not in src, limit your code to Node 6.16 ES! See what's supported here: https://node.green/ (The reason is that our npm library must support earlier versions of Node, so the tests need to run on those versions.)

    How to use with React-Native

    1. Add the following postinstall script:
      yarn rn-nodeify --install url,events,https,http,util,stream,crypto,vm,buffer --hack --yarn
    2. yarn add -D rn-nodeify
    3. Uncomment require('crypto') on shim.js
    4. react-native link react-native-randombytes
    5. Create file rn-cli.config.js
      module.exports = {
      resolver: {
       extraNodeModules: require("node-libs-react-native"),
      },
      };
    6. Add import "./shim"; to the top of index.js
    7. yarn add kuknos-sdk