Now that we have a working smart contract with our desired logic, we can implement the dApp using Truffle and web3.js in a simple React application. Start by importing the required components inside your index.js file:
import React from 'react'
import ReactDOM from 'react-dom'
import MyWeb3 from 'web3'
import './index.styl'
import ABI from '../build/contracts/DAX.json'
import TokenABI from '../build/contracts/ERC20.json'
const batToken = '0x850Cbb38828adF8a89d7d799CCf1010Dc238F665'
const watToken = '0x029cc401Ef45B2a2B2D6D2D6677b9F94E26cfF9d'
const dax = ABI.networks['3'].address
We'll use only two tokens in this prototype for you to learn how to create the application since a fully-featured DAX is outside the scope of this book. The goal is to show you the path so you can...