public async void PrivateRawTransactionTest() { var account = new QuorumAccount("0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7"); var web3Quorum = new Web3Quorum(account, $"{url}:9081", $"{url}:22000"); web3Quorum.SetPrivateRequestParameters(new[] { "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=" }, "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="); var deploymentMessage1 = new StandardTokenDeployment { TotalSupply = 100000 }; var deploymentHandler = web3Quorum.Eth.GetContractDeploymentHandler <StandardTokenDeployment>(); //Deploying var transactionReceipt = await deploymentHandler.SendRequestAndWaitForReceiptAsync(deploymentMessage1); var contractAddress = transactionReceipt.ContractAddress; var totalSupply = await web3Quorum.Eth.GetContractQueryHandler <TotalSupplyFunction>() .QueryAsync <BigInteger>(contractAddress); //var balance = await web3Quorum.Eth.GetContractQueryHandler<BalanceOfFunction>() // .QueryAsync<BigInteger>(contractAddress, // new BalanceOfFunction() { Owner = "0xed9d02e382b34818e88b88a309c7fe71e65f419d" }); //account.Address }); }
public async Task <IHttpActionResult> GetValueForX(int userId) { var contract = _contractRepository.GetAll().ToList() .Where(item => item.Name == CONTRACT_NAME).FirstOrDefault(); if (contract != null) { var user = _userRepository.GetByID(userId); if (user != null) { var userAccount = _userAccountRepository.GetAll().ToList().Where(item => item.UserId == user.Id).FirstOrDefault(); var node = _nodeRepository.GetByID(user.NodeId); if (node != null && userAccount != null) { var accessKey = _accessKeyRepository.GetAll().ToList().Where(item => item.NodeId == node.Id).FirstOrDefault(); if (accessKey != null) { var managedAccount = new QuorumAccount(userAccount.Address); var web3Managed = new Web3Quorum(managedAccount, accessKey.UrlKey); var unlocked = await web3Managed.Personal.UnlockAccount.SendRequestAsync(userAccount.Address, userAccount.Password, 120); var service = new HelloService(web3Managed, contract.Address); var contractHandler = service.ContractHandler; /// Receipt is coming as null var receipt2 = await service.GetMessageQueryAsync( new GetMessageFunction() ); return(Ok(receipt2)); } } } } return(Ok("Cannot value for X ")); }
public IHttpActionResult Post(int userid, int nooflots, int tolerance) { Bid bid = new Bid() { UserId = userid, NoOfLots = nooflots, Tolerace = tolerance }; bids.Add(bid); var bidTransactionReceipt = asyncReceiptDeployTokenBidAsync(bidDeploymentHandlerOut, bidDeploymentMessageOut).Result; var bidContractAddress = transactionReceipt.ContractAddress; accountOut = new QuorumAccount(accountAddress[1]); web3QuorumOut = new Web3Quorum(accountOut, uri[1]); var unlockedOut = asyncUnlockAccount(web3QuorumOut, accountAddress[1]).Result; var bidTrasnferHandlerOut = web3QuorumOut.Eth.GetContractTransactionHandler <ExecuteBid>(); var bidTransfer = new ExecuteBid() { Bond_Id = "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Bid_Min_Price = 970, Bid_Max_Price = 980, Lots_Bid = 1 }; bidTransfer.Gas = 0; var bidTransactionReceipt1 = asyncExecuteBid(bidContractAddress, bidTransfer, bidTrasnferHandlerOut).Result; var bidTrasanctionHas3 = transactionReceipt2.TransactionHash; accountOut = new QuorumAccount(accountAddress[2]); web3QuorumOut = new Web3Quorum(accountOut, uri[2]); unlockedOut = asyncUnlockAccount(web3QuorumOut, accountAddress[2]).Result; bidTrasnferHandlerOut = web3QuorumOut.Eth.GetContractTransactionHandler <ExecuteBid>(); bidTransfer = new ExecuteBid() { Bond_Id = "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Bid_Min_Price = 970, Bid_Max_Price = 980, Lots_Bid = 10 }; bidTransfer.Gas = 0; bidTransactionReceipt1 = asyncExecuteBid(bidContractAddress, bidTransfer, bidTrasnferHandlerOut).Result; bidTrasanctionHas3 = transactionReceipt2.TransactionHash; accountOut = new QuorumAccount(accountAddress[1]); web3QuorumOut = new Web3Quorum(accountOut, uri[1]); unlockedOut = asyncUnlockAccount(web3QuorumOut, accountAddress[1]).Result; var bidValueFromNodeHandlerOut = web3QuorumOut.Eth.GetContractQueryHandler <BidValueForNodeFunction>(); var bidOfnvFunctionMessage = new BidValueForNodeFunction() { InvestoAddress = accountAddress[1] }; return(Ok()); }
public async Task <IHttpActionResult> DeployContracts() { var user = _quorumUserRepository.GetAll().Where(item => item.Id == 7).FirstOrDefault(); var admin = _quorumNodeRepository.GetAll().Where(item => item.Id == 1).FirstOrDefault(); //.Where(item => item.Id == user.QuorumNodeId).FirstOrDefault(); QuorumAccount accountOut = new QuorumAccount(user.AccountAddress); var web3QuorumOut = new Web3Quorum(accountOut, admin.Uri); var unlockedOut = await asyncUnlockAccount(web3QuorumOut, user.AccountAddress); var deploymentHandlerOut = web3QuorumOut.Eth.GetContractDeploymentHandler <EIP20DeploymentBase>(); var deploymentMessageOut = new EIP20DeploymentBase { InitialAmount = 9000000, TokenSymbol = "NwmT", TokenName = "NatwestToken", DecimalUnits = 8 }; deploymentMessageOut.GasPrice = 0; var transactionReceipt = await asyncReceiptDeployTokenAsync(deploymentHandlerOut, deploymentMessageOut); var contractAddress = transactionReceipt.ContractAddress; QuorumAccount accountOut2 = new QuorumAccount(user.AccountAddress); var web3QuorumOut2 = new Web3Quorum(accountOut2, admin.Uri); var unlockedOut2 = await asyncUnlockAccount(web3QuorumOut2, user.AccountAddress); var deploymentHandlerOut2 = web3QuorumOut2.Eth.GetContractTransactionHandler <TransferFunction>(); var user8 = _quorumUserRepository.GetAll().Where(item => item.Id == 8).FirstOrDefault(); var admin2 = _quorumNodeRepository.GetAll().Where(item => item.Id == 2).FirstOrDefault(); var transfer = new TransferFunction() { To = user8.AccountAddress, Value = 300000 }; transfer.GasPrice = 0; var transactionReceipt2 = await asyncTransferAmount(contractAddress, transfer, deploymentHandlerOut2); var transactionHash2 = transactionReceipt2.TransactionHash; var user9 = _quorumUserRepository.GetAll().Where(item => item.Id == 9).FirstOrDefault(); var admin3 = _quorumNodeRepository.GetAll().Where(item => item.Id == 3).FirstOrDefault(); var transfer2 = new TransferFunction() { To = user9.AccountAddress, Value = 300000 }; transfer.GasPrice = 0; var transactionReceipt3 = await asyncTransferAmount(contractAddress, transfer2, deploymentHandlerOut2); var transactionHash3 = transactionReceipt3.TransactionHash; var user10 = _quorumUserRepository.GetAll().Where(item => item.Id == 10).FirstOrDefault(); var admin4 = _quorumNodeRepository.GetAll().Where(item => item.Id == 4).FirstOrDefault(); var transfer3 = new TransferFunction() { To = user10.AccountAddress, Value = 300000 }; transfer.GasPrice = 0; //transfer.Gas = 3000000; var transactionReceipt4 = await asyncTransferAmount(contractAddress, transfer, deploymentHandlerOut2); //await deploymentHandlerOut2.SendRequestAndWaitForReceiptAsync("0x882138260be6fe8d6014d5419ace001c400cce2c", transfer); var transactionHash = transactionReceipt2.TransactionHash; ////////////////////////////////////////////////////////////////////// var bidDeploymentHandlerOut = web3QuorumOut.Eth.GetContractDeploymentHandler <BookRunner>(); var bidDeploymentMessageOut = new BookRunner { TokenAddress = contractAddress, Investor = user.AccountAddress, Name = "Tesla Bond", ISIN = "HFU34HR34", DecimalUnits = 8, Lead_Book_Runner = user.AccountAddress, Inv_type = "Runner", Bond_Name = "Tesla Bond", Bond_Min_Price = 950, Bond_Max_Price = 1000, Bond_Total_Lots = 1000 }; deploymentMessageOut.GasPrice = 0; var bidTransactionReceipt = await asyncReceiptDeployTokenAsync(deploymentHandlerOut, deploymentMessageOut); var bidContractAddress = transactionReceipt.ContractAddress; SqlContext d = new SqlContext(); var contract = d.Contracts.FirstOrDefault(x => x.Name.Equals("BookRunner", StringComparison.CurrentCultureIgnoreCase)); if (contract != null) { contract.Address = bidContractAddress; } else { d.Contracts.Add(new Contract() { Name = "BookRunner", Address = bidContractAddress, ByteCode = BookRunner.BYTECODE }); } return(Ok()); }