I have been coding a bot that accept crypto payments to update balance for user. Checking balance is fine; works great.
When it runs the check command to check if positive balance it then needs to transfer that balance to another wallet.
I am using two addresses of which I control both private keys for testing. I have topped up $5 worth of ETH.
When it runs the send transaction command, I get these errors:
1/2 inner exception
HttpRequestException: No connection could be made because the target machine actively refused it.
2/2 inner exception
SocketException: No connection could be made because the target machine actively refused it.
Here is the method I am running:
private static async void check(String id)
{
string[] data = readdata(id);
var publicKey = data[2];
var privateKey = data[3];
var web3 = new Nethereum.Web3.Web3("https://mainnet.infura.io/v3/APIKEY");
var txCount = web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync(publicKey);
var balance = web3.Eth.GetBalance.SendRequestAsync(publicKey);
var etherAmount = Web3.Convert.FromWei(balance.Result);
Console.WriteLine(etherAmount);
var account = new Account(privateKey);
var web33 = new Web3(account);
var toAddress = "0xEee945DE85Af571940324De312D5077843767A1F";
var transaction = await web33.Eth.GetEtherTransferService().TransferEtherAndWaitForReceiptAsync(toAddress, 1.11m);
Console.WriteLine(transaction.Status);
}