public async Task <IActionResult> PollReceipt(string id)
        {
            Receipt res;

            try
            {
                using (var context = new ApplicationDbContext())
                {
                    var contract = context.DeployedContracts.Where(p => p.TransactionHash == id).FirstOrDefault();

                    ContractAccess contractAccess = new ContractAccess(contract.Network);
                    var            receipt        = await contractAccess.PollReceipt(id);

                    res = new Receipt(receipt);
                    context.Entry(contract).Entity.Receipt = res;

                    context.DeployReceipt.Add(res);
                    await context.SaveChangesAsync();
                }
                return(PartialView("~/Views/Home/_Receipt.cshtml", res));
            }
            catch (Exception e) {
                return(PartialView("~/Views/Shared/Error.cshtml"));
            }
        }
        public async Task <IActionResult> DeployContract(DeployContractVM contractVM)
        {
            try
            {
                ContractParam  contractParam   = new ContractParam(contractVM);
                ContractAccess contractAccess  = new ContractAccess((int)contractVM.Network);
                var            transactionHash = await contractAccess.DeployContract(contractParam);


                Escrow newContract = new Escrow(transactionHash.ToString(), contractVM);

                using (var _context = new ApplicationDbContext())
                {
                    _context.DeployedContracts.Add(newContract);

                    await _context.SaveChangesAsync();

                    //contractVM.ContractList = await _context.DeployedContracts.Include(p => p.Receipt).ToListAsync();
                }
                Log.Information("Contract Deployed at network: " + contractVM.Network.ToString() + ", TxHash: " + transactionHash);
                return(new JsonResult(transactionHash));
            }
            catch (Exception e)
            {
                return(new JsonResult(e.Message));
            }
        }
        public async Task <IActionResult> ShowEstimatedGasPrice(DeployContractVM contractVM)
        {
            ContractAccess contractAccess = new ContractAccess((int)contractVM.Network);
            ContractParam  param          = new ContractParam(contractVM);
            var            gasPrice       = await contractAccess.GetGasLimit(param);

            return(new JsonResult(gasPrice));
        }
        public async Task <ActionResult> Details(int id)
        {
            Escrow res;

            using (var _context = new ApplicationDbContext())
            {
                res = await _context.DeployedContracts.Include(p => p.Receipt).Where(p => p.ID == id).FirstOrDefaultAsync();
            }
            ContractAccess contractAccess = new ContractAccess(res.Network);
            var            rec            = await contractAccess.PollReceipt(res.TransactionHash);

            res.Receipt = new Receipt(rec);
            return(View(res));
        }