/// <summary> /// Transferring funds to a newly created account /// </summary> /// <param name="from">Source Account</param> /// <param name="to">Destination Account</param> /// <returns></returns> private async Task <string> PerformInitials(Account from, Account to) { Web3 web3 = new Web3(from, this.serverUrl); ITransactionReceiptService transactionPolling = web3.TransactionManager.TransactionReceiptService; BigInteger currentBalance = await web3.Eth.GetBalance.SendRequestAsync(to.Address); TransactionReceipt hash = await transactionPolling.SendRequestAndWaitForReceiptAsync(() => web3.TransactionManager.SendTransactionAsync(from.Address, to.Address, new HexBigInteger(howManyTransfer)) ); BigInteger status = BigInteger.Parse(hash.Status.ToString(), NumberStyles.AllowHexSpecifier); if (status != 1) { throw new Exception("error concerning transfer status"); } BigInteger afterBalance = await web3.Eth.GetBalance.SendRequestAsync(to.Address); if (currentBalance != afterBalance) { return(hash.TransactionHash); } return(string.Empty); }
public Task <TransactionReceipt> SetAsyncAndGetReceipt(string addressFrom, string registrationIdentifier, string subject, string value, ITransactionReceiptService transactionReceiptService, HexBigInteger gas = null, HexBigInteger valueAmount = null, CancellationTokenSource cancellationTokenSource = null) { return(transactionReceiptService.SendRequestAndWaitForReceiptAsync( () => SetAsync(addressFrom, registrationIdentifier, subject, value, gas, valueAmount), cancellationTokenSource)); }