Discovery
To find servers that support a token pair, clients call the getURLsForToken function on the Registry contract for each token and then intersect the results. For example, if the resulting URLs for token A are [maker1.com, maker2.com] and for token B are [maker2.com, maker3.com] then the only server supporting swapping token A for B is maker2.com.
See getURLsForToken on the Registry contract:
1
function getURLsForToken(address token) external view returns (string[] memory urls);
Copied!
Check deployments for latest contract addresses for Registry.

Connections

When connecting via HTTP, the server may respond with status code 426 (Upgrade Required) in which case the client should connect using WebSocket.

TypeScript

Using the Registry library from @airswap/protocols can return Server objects that implement the RFQ API.
1
import { Registry } from '@airswap/protocols'
2
const servers = await new Registry(chainId, provider).getServers(
3
signerToken,
4
senderToken,
5
)
Copied!
Calling the Registry directly using ethers
1
import { ethers } from 'ethers'
2
import { chainNames } from '@airswap/constants'
3
import * as RegistryContract from '@airswap/registry/build/contracts/Registry.sol/Registry.json'
4
import * as registryDeploys from '@airswap/registry/deploys.js'
5
const RegistryInterface = new ethers.utils.Interface(
6
JSON.stringify(RegistryContract.abi),
7
)
8
9
new ethers.Contract(
10
registryDeploys[chainId],
11
RegistryInterface,
12
ethers.getDefaultProvider(chainNames[chainId].toLowerCase()),
13
)
14
15
const signerTokenURLs = await this.contract.getURLsForToken(signerToken)
16
const senderTokenURLs = await this.contract.getURLsForToken(senderToken)
17
18
const serverURLs = signerTokenURLs.filter((value) =>
19
senderTokenURLs.includes(value),
20
)
Copied!

Using the CLI

Ensure the AirSwap CLI is installed.
1
$ yarn global add airswap
Copied!
Use airswap chain to set your chain to Rinkeby or Mainnet.
1
$ airswap chain
2
AirSwap CLI 1.6.1 — https://airswap.io/
3
4
set the active ethereum chain
5
6
Current chain: 4 (RINKEBY)
7
8
New chain: (1=mainnet, 4=rinkeby, 5=goerli, 42=kovan, 56=binance): (4) 1
9
10
Set active chain to MAINNET.
Copied!
Use registry:get to fetch server URLs for a token pair.
1
$ airswap registry:get
2
AirSwap CLI 1.6.1 — https://airswap.io/
3
4
get urls from the registry MAINNET
5
6
Registry 0x8F9DA6d38939411340b19401E8c54Ea1f51B8f95
7
8
Token pair (e.g. WETH/USDT): DAI/WETH
9
10
Server
11
----------------------------------------
12
https://maker.example.com/
Copied!
Last modified 24d ago