# 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.*](#user-content-fn-1)[^1]

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:

```javascript
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:

```javascript
const dex = SDK.init( config )
```

<mark style="color:blue;">`config`</mark> is an Object with format:

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

<mark style="color:yellow;">`SDK.init()`</mark> 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.

<mark style="color:yellow;">`SDK.init()`</mark> will throw an exception if there are any errors in <mark style="color:blue;">`config`</mark> or any errors connecting to the network - thus it is advisable to call this function in a try/catch block.

[^1]:
