Server

Servers are processes that implement the Quote and Order APIs using JSON-RPC 2.0 over HTTPS.

Server Client

Add the @airswap/protocols package to your application.

$ yarn add @airswap/protocols

Import the Server client.

import { Server } from '@airswap/protocols'

constructor

Create a new Server client.

public constructor(locator: string)

Param

Type

Optionality

Description

locator

string

required

URL of the server, If no scheme provided, https is implied

Example Create a client to connect to https://maker.example.com/.

const server = new Server('maker.example.com')

Example Create a client to connect to a local development server.

const server = new Server('http://localhost:3000')

Quotes

Servers implement the Quote API.

Example Call getMaxQuote on a local development Server.

const server = new Server('http://localhost:3000')
const quote = await server.getMaxQuote(senderToken, signerToken)

Orders

Servers implement the Order API.

Example Call getSenderSideOrder on a local development Server.

const wallet = new ethers.Wallet('...')
const server = new Server('http://localhost:3000')
const quote = await server.getSenderSideOrder(
signerAmount,
signerToken,
senderToken,
wallet.address,
)