Initiating a sell order

Sell requests that are submitted by the user are processed by the Sell() method. The Sell() method works similarly to the Buy() method that we discussed earlier. The only difference is that in the case of processing and executing a sell request, we check if the current sell price is less than, or equal to, the buy orders in the buys[] array. If this criterion is met, only then are there matching orders available.

The input parameter in the trade method for sell is 2. Thus, anytime the trade method is called for a sell trade, we need to send the trade_type input parameter as 2 to the orderbook smart contract:

contractOB.methods.trade(buys[counter].OrderNo,OrderAmount
,OrderPrice, 2)
.send({from: app.web3.eth.defaultAccount}).then(function(response){

As with the buy side, every time an order is added or a successful buy trade is carried out, the watchOrderbook listener captures the event and sets the orderbook. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.89.85