public void Deploy(string ownerPrivteKey, string nodeUrl) { _account = new Account(ownerPrivteKey); _web3 = new Web3(_account, nodeUrl); _contractInfo = GetContractInfo(); if (contractAddress == string.Empty) { var senderAddress = _account.Address; var transactionHash = _web3.Eth.DeployContract.SendRequestAsync(_contractInfo.GetAbi(), _contractInfo.ByteCode, senderAddress, DefaultGas, new object[] { }).GetAwaiter().GetResult(); var receipt = _web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash).GetAwaiter().GetResult(); while (receipt == null) { Thread.Sleep(1000); receipt = _web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash).GetAwaiter().GetResult(); } contractAddress = receipt.ContractAddress; CreateGame(GameMove.Rock, GameMove.Rock, GameMove.Rock); CreateGame(GameMove.Rock, GameMove.Rock, GameMove.Rock); CreateGame(GameMove.Rock, GameMove.Rock, GameMove.Rock); CreateGame(GameMove.Rock, GameMove.Rock, GameMove.Rock); CreateGame(GameMove.Rock, GameMove.Rock, GameMove.Rock); CreateGame(GameMove.Paper, GameMove.Scissors, GameMove.Paper); CreateGame(GameMove.Scissors, GameMove.Paper, GameMove.Scissors); AcceptGame(0, GameMove.Paper, GameMove.Rock, GameMove.Rock); var res = GetCompletedByIndex(0); } }
public void Deploy(string ownerPrivteKey, string nodeUrl) { _account = new Account(ownerPrivteKey); _web3 = new Web3(_account, nodeUrl); _contractInfo = GetContractInfo(); if (contractAddress == string.Empty) { var senderAddress = _account.Address; var transactionHash = _web3.Eth.DeployContract.SendRequestAsync(_contractInfo.GetAbi(), _contractInfo.ByteCode, senderAddress, DefaultGas, new object[] { }).GetAwaiter().GetResult(); var receipt = _web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash).GetAwaiter().GetResult(); while (receipt == null) { Thread.Sleep(1000); receipt = _web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash).GetAwaiter().GetResult(); } contractAddress = receipt.ContractAddress; AddNewProduct("Cheese 1kg", 50, 100); AddNewProduct("iPhone XX", 1500, 10); AddNewProduct("Smart TV", 1000, 10); AddNewProduct("Toilet paper", 20, 1000); AddNewProduct("Product 10", 20, 500); } }
private Contract GetContract() { return(_web3.Eth.GetContract(_contractInfo.GetAbi(), contractAddress)); }