private static async Task TestService(string fromAddress, string password) { var account = new ManagedAccount(fromAddress, password); var web3 = new Web3Geth(account, Endpoint); bool deployNewContract = true; string contractAddress = null; if (deployNewContract) { var gasForDeployContract = new HexBigInteger(3000000); Console.WriteLine("Deploying contract"); contractAddress = await SimpleStorageContractService.DeployContractAsync(web3, fromAddress, 1, "mstack.nl", null, gasForDeployContract); Console.WriteLine($"Deploying contract done, address = {contractAddress}"); } // Create an instance from the SimpleStorageContractService service which abstracts all calls to the SmartContract. ISimpleStorageContractService service = new SimpleStorageContractService(web3, contractAddress); var setNumberResult = await service.ExecuteTransactionAsync(srv => srv.SetNumberAsync(fromAddress, 500)); var getNumberValue = await service.GetNumberCallAsync(fromAddress); Console.WriteLine($"The stored number value is '{getNumberValue}'."); var setStringResult = await service.ExecuteTransactionAsync(srv => srv.SetStringAsync(fromAddress, "mstack.nl test")); var getStringValue = await service.GetStringCallAsync(fromAddress); Console.WriteLine($"The stored string value is '{getStringValue}'."); }
private static async Task TestOther() { Console.WriteLine("TestOther"); var web3 = new Web3Geth(Account, Endpoint); ISimpleStorageContractService service = new SimpleStorageContractService(web3, _contractAddress); string s1 = await service.GetStringCallAsync(AccountAddress); Console.WriteLine($"GetStringCallAsync: {s1}"); await service.ExecuteTransactionAsync(srv => srv.SetStringAsync(AccountAddress, "stef_" + DateTime.Now)); string s2 = await service.GetStringCallAsync(AccountAddress); Console.WriteLine($"GetStringCallAsync: {s2}"); }
private static async Task TestService(string fromAddress, string password) { var account = new ManagedAccount(fromAddress, password); var web3 = new Web3Geth(account, "http://???.westeurope.cloudapp.azure.com:8545/"); // TODO 2 bool deployNewContract = true; string contractAddress = null; if (deployNewContract) { var gasForDeployContract = new HexBigInteger(1500000); Console.WriteLine("Deploying contract (can take some time)"); contractAddress = await SimpleStorageContractService.DeployContractAsync(web3, fromAddress, 1, "mstack.nl", null, gasForDeployContract).ConfigureAwait(false); Console.WriteLine($"Deploying contract done, address = {contractAddress}"); } // Create an instance from the SimpleStorageContractService service which // abstracts all calls to the SmartContract. ISimpleStorageContractService service = new SimpleStorageContractService(web3, contractAddress); var setNumberResult = await service.ExecuteTransactionAsync(srv => srv.SetNumberAsync(fromAddress, 500)).ConfigureAwait(false); Console.WriteLine($"setNumberResult = '{setNumberResult}'."); var getNumberValue = await service.GetNumberCallAsync(fromAddress).ConfigureAwait(false); Console.WriteLine($"The stored number value is '{getNumberValue}'."); var setStringResult = await service.ExecuteTransactionAsync(srv => srv.SetStringAsync(fromAddress, "mstack.nl test")); Console.WriteLine($"setStringResult = '{setStringResult}'."); var getStringValue = await service.GetStringCallAsync(fromAddress).ConfigureAwait(false); Console.WriteLine($"The stored string value is '{getStringValue}'."); }