Skip to content

Commit db2b05d

Browse files
committed
Add console-app-ropsten
1 parent 5cc575e commit db2b05d

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="..\Solidity\contracts\build\ISimpleStorageContractService.Generated.cs" Link="ISimpleStorageContractService.Generated.cs" />
10+
<Compile Include="..\Solidity\contracts\build\SimpleStorageContractService.ConsoleApp.cs" Link="SimpleStorageContractService.ConsoleApp.cs" />
11+
<Compile Include="..\Solidity\contracts\build\SimpleStorageContractService.Generated.cs" Link="SimpleStorageContractService.Generated.cs" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="Nethereum.Geth" Version="3.0.0" />
16+
<PackageReference Include="Nethereum.Web3" Version="3.0.0" />
17+
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Numerics;
3+
using System.Threading.Tasks;
4+
using DefaultNamespace;
5+
using Nethereum.Geth;
6+
using Nethereum.Hex.HexTypes;
7+
using Nethereum.Web3.Accounts;
8+
9+
namespace ConsoleAppRopsten
10+
{
11+
static class Program
12+
{
13+
private const string Endpoint = "https://ropsten.infura.io/v3/f4cdb4bfdc9d40078ac87d737f1d5c9f";
14+
15+
private static string AccountAddress = "0xB2177c1A1BB4B81cd218f791a7cF792D60C9B3e0";
16+
17+
// https://nethereum.readthedocs.io/en/latest/Nethereum.Workbooks/docs/nethereum-using-account-objects/#sending-a-transaction
18+
private static readonly Account Account = new Account("3351FD107238FDC877840015AFD2009225473F24180550D0A0FE7F92FFEFACCE");
19+
20+
private static string _contractAddress = "0x28aec8f8ddaa699cfe1786848f363d07101966b8";
21+
22+
public static void Main(string[] args)
23+
{
24+
TestService().Wait(15 * 60 * 1000);
25+
}
26+
27+
private static async Task TestService()
28+
{
29+
var web3 = new Web3Geth(Account, Endpoint);
30+
31+
var balance = await web3.Eth.GetBalance.SendRequestAsync(AccountAddress);
32+
Console.WriteLine($"Current balance = {balance.Value}");
33+
34+
Console.WriteLine("Deploying Contract...");
35+
_contractAddress = await SimpleStorageContractService.DeployContractAsync(web3, AccountAddress, new BigInteger(5), "xx", null, new HexBigInteger(1000000));
36+
Console.WriteLine($"Deploying Contract done. Address = {_contractAddress}"); //
37+
38+
await TestOther();
39+
}
40+
41+
private static async Task TestOther()
42+
{
43+
Console.WriteLine("TestOther");
44+
var web3 = new Web3Geth(Account, Endpoint);
45+
46+
ISimpleStorageContractService service = new SimpleStorageContractService(web3, _contractAddress);
47+
48+
string s1 = await service.GetStringCallAsync(AccountAddress);
49+
Console.WriteLine($"GetStringCallAsync: {s1}");
50+
51+
await service.ExecuteTransactionAsync(srv => srv.SetStringAsync(AccountAddress, "stef_" + DateTime.Now));
52+
53+
string s2 = await service.GetStringCallAsync(AccountAddress);
54+
Console.WriteLine($"GetStringCallAsync: {s2}");
55+
}
56+
}
57+
}

Solution.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleAppGanache", "Lab 5
2323
EndProject
2424
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatternCodeGen", "Lab 5 (Azure Accelerators)\PatternCodeGen\PatternCodeGen.csproj", "{2403094D-F47F-445A-9A02-7BCEA236EDBB}"
2525
EndProject
26+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleAppRopsten", "Lab 2 - Completed\ConsoleAppRopsten\ConsoleAppRopsten.csproj", "{EB742D7E-69D1-40FF-B321-DE4C7863C95D}"
27+
EndProject
2628
Global
2729
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2830
Debug|Any CPU = Debug|Any CPU
@@ -49,6 +51,10 @@ Global
4951
{2403094D-F47F-445A-9A02-7BCEA236EDBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
5052
{2403094D-F47F-445A-9A02-7BCEA236EDBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
5153
{2403094D-F47F-445A-9A02-7BCEA236EDBB}.Release|Any CPU.Build.0 = Release|Any CPU
54+
{EB742D7E-69D1-40FF-B321-DE4C7863C95D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55+
{EB742D7E-69D1-40FF-B321-DE4C7863C95D}.Debug|Any CPU.Build.0 = Debug|Any CPU
56+
{EB742D7E-69D1-40FF-B321-DE4C7863C95D}.Release|Any CPU.ActiveCfg = Release|Any CPU
57+
{EB742D7E-69D1-40FF-B321-DE4C7863C95D}.Release|Any CPU.Build.0 = Release|Any CPU
5258
EndGlobalSection
5359
GlobalSection(SolutionProperties) = preSolution
5460
HideSolutionNode = FALSE
@@ -63,6 +69,7 @@ Global
6369
{FE647C6F-892F-405D-8350-4BA9833A4DE8} = {618A4FA3-FE78-4C80-838C-0D957CBD57B8}
6470
{5ED5921A-CEE9-496C-93D6-7BCA44C5306A} = {FE647C6F-892F-405D-8350-4BA9833A4DE8}
6571
{2403094D-F47F-445A-9A02-7BCEA236EDBB} = {FE647C6F-892F-405D-8350-4BA9833A4DE8}
72+
{EB742D7E-69D1-40FF-B321-DE4C7863C95D} = {BC152ADB-E181-46F2-A6BB-2869ED59CE53}
6673
EndGlobalSection
6774
GlobalSection(ExtensibilityGlobals) = postSolution
6875
SolutionGuid = {221B3403-988D-432B-9DCF-E4A108963E6A}

Solution.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ropsten/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)