Skip to content

Instantly share code, notes, and snippets.

@nnzo
Last active August 27, 2019 10:57
Show Gist options
  • Save nnzo/8661bc98973ff3851e874d7c548cf838 to your computer and use it in GitHub Desktop.
Save nnzo/8661bc98973ff3851e874d7c548cf838 to your computer and use it in GitHub Desktop.
0x more in-depth documentation.

Donate! Please, if this helped you, consider donating :)

ETH: 0x709453D46915C562d88CEC34fA948ed7519c190f

BTC: 1LemonR7fZvco7Hg36ZNjy2MKKjhRgUwji

DASH: XffXBUTCyvWnLRtwvp1i8qFfzGr12XAZmd

LTC: LhGHVFynWALCSHAg42JrmWaDXknK1PWYZN

How to setup fully coustom 0x implementation without docker

Prerequisites:

  • Fresh Install of an Ubuntu 16.04 server. ($50 free credit on Vultr using my ref link)
  • NodeJS > v8.x (guide)
  • Yarn > v1.x (npm install yarn -g)
  • Git (sudo apt-get install git)

Clone both repositories

You can fork them to your own Github account, it does not matter. The two repos we will need, are: https://github.com/0x-Dex/0x-launch-kit-frontend, and https://github.com/0x-Dex/0x-launch-kit-backend.

 git clone https://github.com/0x-Dex/0x-launch-kit-frontend frontend
 git clone https://github.com/0x-Dex/0x-launch-kit-backend backend

Setup backend

We have a choice to use Typescript or Javascript. This guide will cover Javascript. (Typescript coming soon ;)

 cd backend
 rm -rf ts

Now run nano package.json, and remove all the lines under 'script' ending with :ts.

We will now setup the config for backend.

 nano js/config.js

Under WHITELISTED_TOKENS, replace the arrary with '*'

Your code should look like this:

 exports.WHITELISTED_TOKENS = _.isEmpty(process.env.WHITELIST_ALL_TOKENS)
     ? '*'
     : assertEnvVarType('WHITELIST_ALL_TOKENS', process.env.WHITELIST_ALL_TOKENS, EnvVarType.WhitelistAllTokens);

Change NETWORK_ID to 1. (Mainnet)

Your code should look like this:

 exports.NETWORK_ID = _.isEmpty(process.env.NETWORK_ID)
     ? 1
     : assertEnvVarType('NETWORK_ID', process.env.NETWORK_ID, EnvVarType.NetworkId);

Change FEE_RECIPEINT to your own address, (e.g. '0x709453D46915C562d88CEC34fA948ed7519c190f')

I think you got the hang of this now, I don't need to show you an example.

Now that we have finished up with the config, you can save and exit nano.

We can now run yarn, to install the dependencies.

 yarn

Once yarn has finished doing it's majic, we can run yarn start:js to, obviously, start our backend!

 yarn start:js

You can also run this inside a program called tmux, to run it in the background.

 tmux
 cd ~/backend
 yarn start:js

Exit tmux using CTRL + B then hitting D.

We can check and make sure our relayer/backend is running correctly using this command.

 curl http://localhost:3000/v2/orders

If everything worked as expected, you should see this:

 {
     "total": 0,
     "page": 0,
     "perPage": 20,
     "records": []
 }

Congrats! We have finished with backend :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment