โ ๏ธ Deprecation Warning ๏ธ๏ธโ ๏ธ
This project is no longer being actively maintained. To fork or run a Standard Relayer API instance, you can use the 0x API instead.
Table of contents
- Introduction
- Language choice
- Getting started
- Client for your relayers API
- Commands
- Database
- Deployment
- Legal Disclaimer
Introduction
Launch a 0x relayer in under a minute with Launch Kit. This repository contains an open-source, free-to-use 0x relayer template that you can use as a starting point for your own project.
- Quickly launch a market for your community token
- Seemlessly create an in-game marketplace for digital items and collectibles
- Enable trading of any ERC-20 or ERC-721 asset
Fork this repository to get started!
See website
Language choice
0x-launch-kit-backend
ships with 2 codebases, one in Typescript and another in Javascript. Although the Javascript is auto-generated from the Typescript, we made sure the Javascript generated is readable.
Before you start using 0x-launch-kit-backend
, choose whether you want your codebase to be in Typescript or Javascript.
If you want to work in Javascript:
- delete the
ts
directory - delete all scripts from
package.json
that end with:ts
Note: If you also wish to build and use the Docker image, please update the command in the Dockerfile to CMD [ "forever", "js/index.js" ]
If you want to work in Typescript:
- delete the
js
directory - delete all scripts from
package.json
that end with:js
Getting started
Pre-requirements
- Node.js > v8.x
- Yarn > v1.x
- 0x Mesh > v5.0.1 for v3. Docker image
0xorg/mesh:5.0.1-beta-0xv3
or greater
To develop ontop of 0x-launch-kit
, follow the following instructions:
-
Fork this repository
-
Clone your fork of this repository
-
Open the
config.ts
/config.js
file (depending on the language you've chosen above) and edit the whitelisted tokens:WHITELISTED_TOKENS
-- Which tokens you would like to host orderbooks for.
-
Open the
.env
file and edit the following fields. Defaults are defined inconfig.ts
/config.js
. The bash environment takes precedence over the.env
file. If you runsource .env
, changes to the.env
file will have no effect until you unset the colliding variables.CHAIN_ID
-- the chain you'd like your relayer to run on (e.g:1
-> mainnet,42
-> Kovan, 3 -> Ropsten, etc...). Defaults to42
MESH_ENDPOINT
-- the url pointing to the 0x Mesh node. Defaults tows://localhost:60557
FEE_RECIPIENT
-- The Ethereum address which should be specified as the fee recipient in orders your relayer accepts. Defaults to a fake address that helps the 0x core team use anonymous, already public data to understand Launch Kit developer usage. Defaults to an auto-generated addressMAKER_FEE_ASSET_DATA
-- The maker fee token asset data. Defaults to0x
, i.e no feeMAKER_FEE_UNIT_AMOUNT
-- The flat maker fee amount you'd like to receive for filled orders hosted by you. Defaults to0
MAKER_FEE_ASSET_DATA
-- The taker fee token asset data. Defaults to0x
, i.e no feeTAKER_FEE_UNIT_AMOUNT
-- The flat taker fee you'd like to receive for filled orders hosted by you. Defaults to0
Instructions for using Launch Kit with Ganache
-
Make sure you have Yarn installed.
-
Install the dependencies:
yarn
-
Build the project [This step is for Typescript users only]
yarn build:ts
or build & watch:
yarn watch:ts
Note: There isn't currently a build step when working on the Javascript codebase because we assume
0x-launch-kit
will be running on Node.js > v8.0. If you want this project to work in an environment that doesn't support many of the latest Javascript features, you will need to add a transpiler (e.g Babel) to this project. -
Start the relayer
yarn start:ts
OR
yarn start:js
Client for your relayer's API
Since the 0x-launch-kit-backend
relayer adheres to V3 of the Standard Relayer API Specification, you can use 0x Connect (an HTTP/Websocket client) to make calls to your relayer (e.g submit an order, get all orders, etc...)
Learn how to use 0x Connect to interact with your 0x-launch-kit
relayer in this tutorial.
To quickly check if your relayer is up-and-running, send it this CURL request from the command-line:
curl http://localhost:3000/v3/orders
If everything is working as expected, you should see this response:
{
"total": 0,
"page": 0,
"perPage": 20,
"records": []
}
Since no orders have been added to your relayer yet, the records
array is empty.
Commands
Typescript project commands:
yarn build:ts
- Build the codeyarn lint:ts
- Lint the codeyarn start:ts
- Starts the relayeryarn watch:ts
- Watch the source code and rebuild on changeyarn prettier:ts
- Auto-format the code
Javascript project commands:
yarn start:js
- Start the relayeryarn prettier:js
- Auto-format the code
Database
This project uses TypeORM. It makes it easier for anyone to switch out the backing database used by this project. By default, this project uses an SQLite database.
Because we want to support both Javascript and Typescript codebases, we don't use TypeORM
's decorators (since they don't transpile nicely into readable Javascript). TypeORM shines with decorators however, so you might want to use them if you're going to be working in Typescript.
Deployment
0x-launch-kit
ships as a docker container. First, install Docker (mac, windows). To build the image run:
docker build -t 0x-launch-kit-backend .
You can check that the image was built by running:
docker images
And launch it with
docker run -p 3000:3000 -d 0x-launch-kit-backend
Check that it's working by running
curl http://localhost:3000/v3/asset_pairs
Legal Disclaimer
The laws and regulations applicable to the use and exchange of digital assets and blockchain-native tokens, including through any software developed using the licensed work created by ZeroEx Intl. as described here (the โWorkโ), vary by jurisdiction. As set forth in the Apache License, Version 2.0 applicable to the Work, developers are โsolely responsible for determining the appropriateness of using or redistributing the Work,โ which includes responsibility for ensuring compliance with any such applicable laws and regulations. See the Apache License, Version 2.0 for the specific language governing all applicable permissions and limitations: http://www.apache.org/licenses/LICENSE-2.0