public EstudianteService(IDataAccess data, ScratchService evaluator, DesafioEstudianteService desafioService) { _data = data; _desafioService = desafioService; _evaluator = evaluator; }
public EstudianteService(IDataAccess data, ScratchService evaluator, DesafioEstudianteService desafioService, CalificacionDesafioService calificacionDesafioService) { _data = data; _desafioService = desafioService; _evaluator = evaluator; _calificacionDesafioService = calificacionDesafioService; }
// Method to Initialize Saved Settings. public static void InitializeSettings() { // Initialize contract variables. Configuration configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); KeyValueConfigurationCollection Settings = configFile.AppSettings.Settings; // Initialize Contract Address and ABI variables. ScratchContractAddress = Settings["ScratchContractAddress"].Value; RoundContractAddress = Settings["RoundContractAddress"].Value; CsService = new ScratchService(web3, ScratchContractAddress); RService = new ScratchCardRoundService(web3, RoundContractAddress); }
/* * private static async Task GetLinkPrice() * { * Account a = new Account("d871d74211c60eb4b0baa664961362abcc0c98c6dc533c9e38ace62361dc21f5", null); * * var web3 = new Web3(a, "https://ropsten.infura.io/v3/bf32e2587d834489b5b823d63d08efac"); * * var deployReciept2 = await ScratchLinkClientService.DeployContractAndWaitForReceiptAsync(web3, new ScratchLinkClientDeployment()); * * string ScratchContractAddress2 = deployReciept2.ScratchContractAddress; * * ScratchLinkClientService s2 = new ScratchLinkClientService(web3, ScratchContractAddress2); * * var transferHandler = web3.Eth.GetContractTransactionHandler<TransferFunction>(); * var transfer = new TransferFunction() * { * To = ScratchContractAddress2, * TokenAmount = Web3.Convert.ToWei(1) * }; * * var transactionReceipt = await transferHandler.SendRequestAndWaitForReceiptAsync("0x20fE562d797A42Dcb3399062AE9546cd06f63280", transfer); * * var req = new RequestEthereumPriceFunction(); * * var priceReq = await s2.RequestEthereumPriceRequestAndWaitForReceiptAsync(req); * * while (true) * { * var price = await s2.EthereumPriceQueryAsync(); * * if(price > 0) * { * Console.WriteLine($"Price {price}"); * } * } * * } */ static async Task GetScratchCard(ScratchService s) { //var Filter = await RequestEvent.CreateFilterAsync(); Console.WriteLine("Getting Random Number.."); /* * var rndNum = new GetScratchCardFunction(); * * var Getrnd1 = s.GetScratchCardRequestAndWaitForReceiptAsync(rndNum); * * var Getrnd2 = s.GetScratchCardRequestAndWaitForReceiptAsync(rndNum); * * Getrnd1.Wait(); * * Getrnd2.Wait(); * * Console.WriteLine($"RND1 block: {Getrnd1.Result.BlockNumber}\nRND2 block: {Getrnd2.Result.BlockNumber}"); */ // Logs /* * var RequestEventHandler = s.ContractHandler.GetEvent<RandomNumberRequestEventDTO>(); * * var filterAllRequestEvents = RequestEventHandler.CreateFilterInput(); * * while (true) * { * var allRequestEvents = await RequestEventHandler.GetAllChanges(filterAllRequestEvents); * * foreach(EventLog<RandomNumberRequestEventDTO> r in allRequestEvents) * { * Console.WriteLine($"Random Number: {r.Event.RandomNumber}"); * } * * }*/ }
private static async Task Deploy() { Console.WriteLine("Deploying contract..."); //GetBalance().Wait(); ScratchDeployment SD = new ScratchDeployment { InitialLink = Web3.Convert.ToWei(1) //AmountToSend = 100000000000 }; try { var deployReciept = await ScratchService.DeployContractAndWaitForReceiptAsync(web3, SD); ScratchContractAddress = deployReciept.ContractAddress; Console.WriteLine($"gas: {Web3.Convert.FromWei(Web3.Convert.ToWei(deployReciept.GasUsed, UnitConversion.EthUnit.Gwei))}"); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine($"Scratch contract address: {ScratchContractAddress}"); //var balance = await web3.Eth.GetBalance.SendRequestAsync(ScratchContractAddress); //Console.WriteLine($"Scratch contract Ether: {balance}"); // Open Settings. var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var Settings = configFile.AppSettings.Settings; Settings["ScratchContractAddress"].Value = ScratchContractAddress; CsService = new ScratchService(web3, ScratchContractAddress); var rec1 = CsService.GetLinkBalanceQueryAsync(account.Address); Console.WriteLine($"Account Link Balance: {Web3.Convert.FromWei(rec1.Result)}\n Account Eth Balance: {Web3.Convert.FromWei(await web3.Eth.GetBalance.SendRequestAsync(account.Address))}"); /* * var deposit = new DepositLinkFunction() * { * Value = 1 * };*/ var transferHandler = web3.Eth.GetContractTransactionHandler <TransferFunction>(); var transfer = new TransferFunction() { To = ScratchContractAddress, TokenAmount = Web3.Convert.ToWei(1) }; Console.WriteLine($"Token amount: {transfer.TokenAmount} in wei"); var transactionReceipt = await transferHandler.SendRequestAndWaitForReceiptAsync("0xa36085F69e2889c224210F603D836748e7dC0088", transfer); rec1 = CsService.GetLinkBalanceQueryAsync(ScratchContractAddress); Console.WriteLine($"Link sent to Contract: {Web3.Convert.FromWei(rec1.Result)}"); RoundContractAddress = await CsService.GetCardRoundQueryAsync(); Settings["RoundContractAddress"].Value = RoundContractAddress; RService = new ScratchCardRoundService(web3, RoundContractAddress); // Save Settings configFile.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name); Console.WriteLine("\n"); }
public DesafioService(IDataAccess data, ScratchService scratchService) { _data = data; _scratchService = scratchService; }
public DesafiosController(ScratchService service) { _scratchService = service; }
public HomeController(ScratchService evaluator) { _evaluator = evaluator; }