Skip to content
Example Maker (HTTPS Server) for the AirSwap Network
JavaScript TypeScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

AirSwap: ZEIT Now Serverless Example

Maker Kit includes tools and examples to help you get started on the AirSwap Network.

Discord License Twitter Follow


Requires Node.js v8.10.0 or above and NPM or Yarn.

1. Install Zeit CLI

npm i -g now


yarn global add now

2. Login to Zeit CLI

now login

3. Clone this repo and install dependencies

git clone
cd airswap-maker-example-zeit
yarn install

4. Create a .env file in the root of this directory, modeled after .env.example

Environment variables are loaded from a .env file in the root directory. The following must be set:

  • ETHEREUM_ACCOUNT - The private key of an account to use for staking and trading.
  • ETHEREUM_NODE - The URL of an Ethereum node to connect to.

There is an example .env.example that you can copy to .env to start with.

Ethereum Account

To use an existing Ethereum account, set the ETHEREUM_ACCOUNT in your .env file. Otherwise it's easy to create an account using MetaMask or the yarn utils:account script in the Maker Kit repository. Paste the generated private key into your .env file.

Ethereum Node

To use an existing Ethereum node, set the ETHEREUM_NODE in your .env file. Otherwise you can create a free account with INFURA. Navigate to to create an account and generate an API key and URL.


Command Description
yarn Install dependencies
now dev Run the maker locally
now Deploy your maker to the cloud

Quick Start

The reference Node.js maker is configured to quote WETH/DAI at price 0.1 on port 3000.

Testing your ZEIT maker Locally

  1. From the root of this directory, run now dev
  2. In another command line window, navigate to Maker Kit
  3. Make sure that you've also created an appropriate .env in maker-kit
  4. Run yarn peers:get, press enter through all prompts except "locator". When asked for locator, specify http://localhost:3000
  5. Observe that your Zeit Serverless function successfully serves a quote successfully!

Deploying your ZEIT Maker to the cloud

  1. From the root of this directory, run now
  2. That's all there is to it!

Connecting to a remote server

In some cases it may not be feasible to develop all of your pricing logic inside your ZEIT maker. Maybe your pricing logic is already developed in another programming language, or you have pre existing infrastucture. In these cases, you can simply use ZEIT serverless as a proxy layer that sits between the end user and your remote pricing server. This creates a nice seperation of concerns. The ZEIT maker will handle web details such as CORS and SSL, and it will forward quote/order requests to your remote server for processing.

Follow the steps below to see a demo of this proxy configuration.

  1. In now.json, change the value of the "dest" field on line 16 from "/api/index.ts" to "/api/index.proxy.ts"
  2. In a command line window, run yarn mock-price-server to start a mock server locally on port 1337
  3. In another command line window, run now dev to start the ZEIT process on port 3000
  4. Now, whenever you query your maker on port 3000, you'll see that all the requests get proxied to the mock pricing server.


  • CORS - Makers must run their servers with CORS enabled to accept connections from in-browser web applications including AirSwap Instant.
  • Token Values - All token values are in the smallest indivisible units of a token (wei).
  • Nonce Window - Each order is identified by a unique nonce. The "nonce window" is the time within which every order returned will include the same nonce. This can be configured to prevent overexposure.
  • Trading ETH - Swap only supports tokens, not native ether (ETH). To trade ETH it must be wrapped (WETH).

Helpful for Testing on Rinkeby

  • ETH to pay for transactions - Faucet
  • WETH for trading - 0xc778417e063141139fce010982780140aa0cd5ab Etherscan
  • DAI for trading - 0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea Etherscan
  • AST for staking - 0xcc1cbd4f67cceb7c001bd4adf98451237a193ff8 Etherscan / Faucet
You can’t perform that action at this time.