37 lines
1.0 KiB
C#
Raw Normal View History

using BlockchainUtils;
using Logging;
2023-04-25 11:31:15 +02:00
using Nethereum.Web3;
2023-04-14 10:51:35 +02:00
namespace NethereumWorkflow
{
2023-04-14 12:37:05 +02:00
public class NethereumInteractionCreator
2023-04-14 10:51:35 +02:00
{
2023-09-15 16:27:08 +02:00
private readonly ILog log;
private readonly BlockCache blockCache;
2023-04-14 10:51:35 +02:00
private readonly string ip;
private readonly int port;
2023-04-18 13:22:41 +02:00
private readonly string privateKey;
2023-04-14 10:51:35 +02:00
public NethereumInteractionCreator(ILog log, BlockCache blockCache, string ip, int port, string privateKey)
2023-04-14 10:51:35 +02:00
{
2023-04-25 11:31:15 +02:00
this.log = log;
this.blockCache = blockCache;
2023-04-14 10:51:35 +02:00
this.ip = ip;
this.port = port;
2023-04-18 13:22:41 +02:00
this.privateKey = privateKey;
2023-04-14 10:51:35 +02:00
}
2023-04-14 12:37:05 +02:00
public NethereumInteraction CreateWorkflow()
2023-04-14 10:51:35 +02:00
{
log.Debug("Starting interaction to " + ip + ":" + port);
return new NethereumInteraction(log, CreateWeb3(), blockCache);
2023-04-14 10:51:35 +02:00
}
private Web3 CreateWeb3()
{
2023-04-18 13:22:41 +02:00
var account = new Nethereum.Web3.Accounts.Account(privateKey);
return new Web3(account, $"{ip}:{port}");
2023-04-14 10:51:35 +02:00
}
}
}