January 2020
Intermediate to advanced
530 pages
11h 11m
English
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){ ...Read now
Unlock full access