public async Task <string> ApproveContract(string ContractAddress, string PublicKey) { //approve the contract seny by the seller (send money and sign the contract) DappAccount account = DappAccountController.openWith[PublicKey.ToLower()]; SmartContractService deployedContract = new SmartContractService(account, ContractAddress); double beforeBalanceETH = await DappAccountController.get_ETH_Balance(PublicKey, PublicKey); double beforeBalanceILS = await DappAccountController.get_ILS_Balance(PublicKey, PublicKey); double exchangeRate = DappAccountController.getExchangeRate_ETH_To_ILS(); double afterBalanceETH; double afterBalanceILS; double feeETH; double feeILS; Asset dealAsset = await deployedContract.getAssetDestails(); double ethToPay = dealAsset.Price; bool isPaid = false; bool isSigned = false; isPaid = await deployedContract.sendEtherToContract(ethToPay); if (isPaid == true) { isSigned = await deployedContract.setBuyerSign(); } else { throw new Exception("Out of money"); } afterBalanceETH = await DappAccountController.get_ETH_Balance(PublicKey, PublicKey); afterBalanceILS = await DappAccountController.get_ILS_Balance(PublicKey, PublicKey); feeETH = beforeBalanceETH - (afterBalanceETH + ethToPay); feeILS = exchangeRate * feeETH; ConfirmationRecipt recipt = new ConfirmationRecipt(); recipt.ContractAddress = ContractAddress; recipt.feeETH = feeETH; feeILS = Math.Truncate(feeILS * 100) / 100; //make the double number to be with 3 digits after dot recipt.feeILS = feeILS; var ReciptJson = Newtonsoft.Json.JsonConvert.SerializeObject(recipt); updateOfferToPending(ContractAddress); return(ReciptJson); }