TronWatch
TronWatch
Oct 14, 2018 · 4 min read

As planned, we started development of TronWatch Market the day after reaching softcap. This article is a short update of what we’ve been up to in the last 12 days, and the plans for the next couple of weeks.

The first few days were spent on designing the architecture and individual components of our exchange. The following days were spent implementing basic versions for each of them. Here are some short descriptions, and the development progress that has been made.

Smart Contracts

The most important aspect of the exchange; smart contracts manage users’ funds and facilitate trading. We are aiming to implement the smart contracts as early as possible so to allow adequate time for testing, reviews, and a code audit.

The contracts for trading TRX20 tokens have been implemented, and are feature complete. They support:

  • Trading TRX20 tokens for TRX
  • Depositing / withdrawing TRX*
  • Validating signatures for maker offers
  • Canceling outstanding offers
  • Distributing trading fees (including support for affiliates)
  • Filling batch orders, allowing the frontend to present market and limit orders

* TRX20 tokens are never deposited into our contract. Instead users `approve` the exchange to spend on their behalf, and the contract will then move funds to facilitate trades.

Next steps include thorough testing and optimizing energy usage to ensure interacting with the exchange is as cheap as possible, without sacrificing security. Additionally we need to add support for TXR10 tokens including the ability to purchase a discount on trading fees with TronWatchMarket tokens, support TRX20 base pairs, and create the Listing Manager and DAO contracts.

Website Interface

To help provide our users with a positive and reliable user experience, we have a big focus on the web interface of the DEX. We have taken influence from many of the most popular exchanges on the web and have been working on improving our design to meet both community needs and functionality.

Like with our other projects we’ve decided to use React to build the frontend. React allows us to efficiently produce the frontend while keeping a maintainable codebase. It’s important that we have proper data flows and maintain concise development patterns so that the community are able to build on the frontend. TronWatch Market uses its own bootstrapping system to build the application on the first run, also loading in the appropriate localisation data and token information.

We decided to take a modular approach with styling so SCSS with partials was a perfect fit. To keep it easily maintainable and structured, SCSS provided great features such as nesting and mixins to assist us in doing so. Instead of scrolling through a ton of inheritance and long css selectors, it takes a more DOM based approach which mirrors the JSX very well, making it a breeze to visually parse and update where needed. We compile it all down to vanilla css after, so the variables we use do not need to be polyfilled. When we do need to polyfill, mixins help keep the SCSS file clean and uncluttered.

As with many other TRON DApps, we’re using TronLink for wallet management. TronLink is a chrome extension that allows you to manage your TRX and tokens, whilst also offering websites the ability to interact with the blockchain. This lets users trigger smart contract calls with the click of a button. You can find out more information about TronLink here.

Backend

The backend of our exchange is there to offer a fast api for the information that is off-chain, and events that can’t be queried efficiently using TRON nodes. We have split it into three main components. During the last week we developed early versions for all of them, that are now ready for integration with the frontend.

API

We’ve built a REST API that offers all the endpoints that the frontend (and third-party apps) need:

Misc

  • /v1/chart/:quote/:base
  • /v1/tokens/all
  • /v1/tokens/base
  • /v1/tokens/listed

Orders

  • /v1/orders
  • /v1/orders/:address
  • /v1/orders/:token
  • /v1/orders/publish

Fills

  • /v1/fills
  • /v1/fills/:address
  • /v1/fills/:token
  • /v1/filles/:quote/:base

Events

A process keeps track of events on the TRON blockchain, and stores fills and cancellations in our database. This process also caches chart data as efficiently as possible. We implemented and tested a couple variations and ended up with a system using Redis and MySQL, which should be very easy to set up for whitelabel exchanges, whilst also maintaining efficiency for thousands of trades per second on a consumer desktop pc.

Balances

A script that listens for new blocks on the TRON blockchain. It keeps track of users TRX, TRX10 and TRX20 balances.

At the time of writing the API is feature complete. The balance script is up and running, and the events script is fully implemented although currently using randomly generated mock data.

What’s next?

The next steps are to connect the frontend, API and smart contract altogether.

We plan to have a pre-alpha version online on testnet before the end of our token sale. This version will support TRX and TRX20 tokens.

If you haven’t heard about TronWatchMarket yet, feel free to view our token sale and whitepaper on tronwatch.market. We’re looking to build one of TRON’s first fully-featured Decentralized Exchanges — it will allow you to trade between TRON, TRX10 and TRX20 tokens.

Our Team
TronWatch is formed by a dynamic team of experienced developers from all around the world including Canada, United States, United Kingdom and Germany.

You can find us on:
Twitter: https://twitter.com/tronwatch
Facebook: https://www.facebook.com/tronwatch
Instagram: https://www.instagram.com/TronWatch/
Telegram: https://t.me/TronWatch
Medium: https://medium.com/@TronWatch/
GitHub: https://github.com/TronWatch/

TRON

TRON

TronWatch

Written by

TronWatch

The official medium of TronWatch

TRON

TRON

TRON

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