The next method(s) will accept a buy request from the user. It will first check in the orderbook to see if there is a matching order. If it is unable to find a matching order, it adds the order to the orderbook. The Buy() method handles the buy request and the Sell() method handles the sell request.
Let's look at the Buy() method:
Buy = () => {let app = this; let amount = this.state.fields.buyamount; let price = this.state.fields.buyprice; var contractUSD = new this.web3.eth.Contract(app.USD.abi,app.USD.address); var contractOB = new this.web3.eth.Contract(app.OrderbookABI.abi,app.OrderbookABI.address); var sells = app.state.sells;
- We start by initializing and capturing the amount and the price of the order that is ...