AirSwap Developer Series Part 1: Makers and Takers

AirSwap Team
Jul 26, 2018 · 4 min read

We launched AirSwap for Developers in May of this year. Since then, our community of passionate developers have built volume trackers, custom trading interfaces, desktop applications, and much more.

Seeing all of this happen in just under three months has been awe-inspiring for the team. We want to enable more developers and traders, so today we’re re-launching our developers repository and kicking off a three part guided tutorial to teach you everything you need to know about building on AirSwap.

Makers and Takers

The Swap protocol is a peer-to-peer system. This means that every trade happens directly between two peers — a maker and a taker. One common misconception we see is the notion that a maker is a “seller” and a taker is a “buyer”. This is incorrect.

The maker — let’s call him Bob — is the peer who tells AirSwap that he wants to make a trade. Alice, our fictional taker, then visits AirSwap and searches for trades. She finds Bob’s intent to make orders, so she asks him for one. Bob then makes an order, signs it, and sends it to Alice. At this point, it’s up to Alice whether or not she wants to take the trade.

Now that we’ve gotten that out of the way, let’s dive into the code. The rest of the tutorial will show you the basics of the AirSwap API Server, which is your primary resource as a developer in the ecosystem.

Requirements

Up and Running

  • Open a new command line window and change directory to the freshly cloned repository.
  • Run npm install on the command line.
  • Open a new terminal window and start the server with two required environment variables: PRIVATE_KEY (prepended with “0x”) and MAINNET(0=testnet, 1=mainnet).

You should see the following message printed:

Our API Client Server has successfully connected to AirSwap and Ethereum on the Rinkeby test net! Here is a brief taste of what’s possible now that our local API server is up and running. You can follow along on the command line by pasting the following cURL commands, or you can use your favorite programming language to make HTTP requests. We’re going to make a few POST calls to acquire some test net AST. This test AST doesn’t have any value and we’ll be using it for demonstration purposes only in the next two parts of this educational series.

Find All Makers Trading AST

Get an Order for 250 AST from a Maker

If the maker is online, it should return an object that looks something like this

You’ll need to copy the entire object into the order parameter on the next step. You’ll also need to copy the takerAmount value into the configparameter.

Take the Order

This call should return an object like so:

The hash key in this object is the transaction hash for your order. You can look up that hash on https://rinkeby.etherscan.io to see the result.

Congratulations 🎉

You now own 250 test net AST. Make sure to hang onto it — you’ll need it for Part 2. The API methods referenced in this tutorial can be leveraged to build powerful applications like automated market makers and trading bots. In fact, that’s exactly what we’ll be doing in Part 2 and Part 3 of this tutorial series. Stay tuned!


About AirSwap

AirSwap enables peer-to-peer trading on the Ethereum blockchain. Built on a decentralized protocol, traders can add or remove liquidity through a suite of trustless products that are easy to use and free. Our mission is to empower the world with frictionless trade.

Blog | Twitter | Discord | Developers | Makers | Reddit | Facebook | Linkedin | Subscribe | Support | Request a Feature | FAQ | Trade Now

Fluidity

Rebuilding Finance for a Frictionless World

AirSwap Team

Written by

AirSwap is a peer-to-peer trading network built on Ethereum. Our mission is to empower people through global, frictionless trade.

Fluidity

Fluidity

Rebuilding Finance for a Frictionless World

AirSwap Team

Written by

AirSwap is a peer-to-peer trading network built on Ethereum. Our mission is to empower people through global, frictionless trade.

Fluidity

Fluidity

Rebuilding Finance for a Frictionless World

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store