Portal Swap SDK Overview

The Portal SDK packages classes presenting simple yet powerful interfaces to the Portal DEX, to wallets, and for crypto-asset management in general. This document describes the initial version of the Portal SDK used for interfacing with the Portal DEX to execute swaps of crypto-assets.

The SDK is avilable as a Javascript module that can be imported into browser or server (e.g. node.js) environments:

npm install '@portaldefi/sdk'
import SDK from '@portaldefi/sdk'

The SDK module exports a single function which must be executed in order to access any capabilities of the SDK:

const dex = SDK.init( config )

config is an Object with format:

   network: {
      hostname: String,
      port: Number
   blockchains: {
      bitcoind: Object,
      geth: Object,
      lnd: Object
   swaps: Object

SDK.init() returns an instance of the DEX class representing a connection to a particular instance of the Portal DEX network for a particular user. The interface of the DEX class is specified in the next section.

SDK.init() will throw an exception if there are any errors in config or any errors connecting to the network - thus it is advisable to call this function in a try/catch block.

Last updated