2023-04-25 05:46:09 +00:00
|
|
|
|
using Nethereum.Web3;
|
2023-04-14 08:51:35 +00:00
|
|
|
|
|
|
|
|
|
namespace NethereumWorkflow
|
|
|
|
|
{
|
2023-04-14 10:37:05 +00:00
|
|
|
|
public class NethereumInteractionCreator
|
2023-04-14 08:51:35 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly string ip;
|
|
|
|
|
private readonly int port;
|
|
|
|
|
private readonly string rootAccount;
|
2023-04-18 11:22:41 +00:00
|
|
|
|
private readonly string privateKey;
|
2023-04-14 08:51:35 +00:00
|
|
|
|
|
2023-04-25 05:46:09 +00:00
|
|
|
|
public NethereumInteractionCreator(string ip, int port, string rootAccount, string privateKey)
|
2023-04-14 08:51:35 +00:00
|
|
|
|
{
|
|
|
|
|
this.ip = ip;
|
|
|
|
|
this.port = port;
|
|
|
|
|
this.rootAccount = rootAccount;
|
2023-04-18 11:22:41 +00:00
|
|
|
|
this.privateKey = privateKey;
|
2023-04-14 08:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 10:37:05 +00:00
|
|
|
|
public NethereumInteraction CreateWorkflow()
|
2023-04-14 08:51:35 +00:00
|
|
|
|
{
|
2023-04-25 05:46:09 +00:00
|
|
|
|
return new NethereumInteraction(CreateWeb3(), rootAccount);
|
2023-04-14 08:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Web3 CreateWeb3()
|
|
|
|
|
{
|
2023-04-18 11:22:41 +00:00
|
|
|
|
var account = new Nethereum.Web3.Accounts.Account(privateKey);
|
|
|
|
|
return new Web3(account, $"http://{ip}:{port}");
|
2023-04-14 08:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|