/ Framework / NethereumWorkflow / NethereumInteractionCreator.cs
NethereumInteractionCreator.cs
 1  using BlockchainUtils;
 2  using Logging;
 3  using Nethereum.Web3;
 4  using Utils;
 5  
 6  namespace NethereumWorkflow
 7  {
 8      public class NethereumInteractionCreator
 9      {
10          private readonly ILog log;
11          private readonly BlockCache blockCache;
12          private readonly string ip;
13          private readonly int port;
14          private readonly string privateKey;
15  
16          public NethereumInteractionCreator(ILog log, BlockCache blockCache, string ip, int port, string privateKey)
17          {
18              this.log = log;
19              this.blockCache = blockCache;
20              this.ip = ip;
21              this.port = port;
22              this.privateKey = privateKey;
23          }
24  
25          public NethereumInteraction CreateWorkflow()
26          {
27              log.Debug("Starting interaction to " + ip + ":" + port);
28              return new NethereumInteraction(log, CreateWeb3(), blockCache);
29          }
30  
31          public EthAddress GetEthAddress()
32          {
33              var account = new Nethereum.Web3.Accounts.Account(privateKey);
34              return new EthAddress(account.Address);
35          }
36  
37          private Web3 CreateWeb3()
38          {
39              var account = new Nethereum.Web3.Accounts.Account(privateKey);
40              return new Web3(account, $"{ip}:{port}");
41          }
42      }
43  }