Initiating a buy order

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;
  1. We start by initializing and capturing the amount and the price of the order that is ...

Get Blockchain Development for Finance Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.