Search
K

Portal Swap SDK Overview

This document is for informational purposes only. It is a specification of a product that is under active development and should be expected to change. It does not provide any guarantees or warranties as to how the final product will operate.
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 modified 1mo ago