public IActionResult ChangeNetwork(int id) { DeployContractVM contractVM = new DeployContractVM(); switch (id) { case 0: contractVM.SellerAddress = "0x7AC658F93a3f21187Ef55afd2E47509dc9E63B15"; contractVM.BuyerAddress = "0x87f39fB5D19bB6e673Fec08ee09a97872241de6C"; contractVM.EscrowHolderAddress = "0x987D6639c025354042BB913A503F4532390652ad"; contractVM.EtherToPay = "0.0001"; contractVM.ExpiryDate = DateTime.Now.AddDays(30); contractVM.GasLimit = "67412"; contractVM.Network = Network.Ganache; break; case 1: contractVM.SellerAddress = "0x005e44B5ce1E91c2ee3b6e13B52F174b664b8124"; contractVM.BuyerAddress = "0x002E271cd0b4f04Ca47F12D39d248dDb08D4eDdE"; contractVM.EscrowHolderAddress = "0x004EF9E943EbeecF4d161384666d939b34af9146"; contractVM.EtherToPay = "0.0001"; contractVM.ExpiryDate = DateTime.Now.AddDays(30); contractVM.GasLimit = "67412"; contractVM.Network = Network.Ropsten; break; } return(PartialView("~/Views/Home/_DeployContract.cshtml", contractVM)); }
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 ContractParam(DeployContractVM vM) { SenderAddress = vM.SellerAddress; GasLimit = new Nethereum.Hex.HexTypes.HexBigInteger(vM.GasLimit); var amount = new Nethereum.Hex.HexTypes.HexBigInteger(vM.EtherToPay); GetV = new object[3]; GetV[0] = vM.BuyerAddress; GetV[1] = vM.EscrowHolderAddress; GetV[2] = vM.EtherToPay; }