These are chat archives for Nethereum/Nethereum

Jun 2018
Michael Ilchuk
Jun 18 2018 14:53

Hi guys .

I want to make transaction send all eth , and I had error Message = "insufficient funds for gas * price + value"

For example:
My balance : 10.985379999999999999
I want to send 10.985379999999999999 - > error "insufficient funds for gas price + value"
I want to send 100 eth -> same error "insufficient funds for gas
price + value"

Should I estimate transaction fee and decrease amount to send or should I do something else ?

var gasPrice = await _web3.Eth.GasPrice.SendRequestAsync();
var gas = await _web3.Eth.Transactions.EstimateGas.SendRequestAsync(new CallInput("0x" + transactionEncoded, destanitionAddress));
var feeAmount = gasPrice.Value * gas.Value;
Michael Ilchuk
Jun 18 2018 15:02

Or use


calculate fee and deсrease amount to send ?

Juan Blanco
Jun 18 2018 15:33
Is this a function
or just a transaction
is it in the mainnet?
Michael Ilchuk
Jun 18 2018 15:37
for now, it's test network
Exception on this line.
var txId = await _web3.Eth.Transactions.SendRawTransaction.SendRequestAsync("0x" + transactionEncoded);
transaction for send 10.985379999999999999 to another eth account
for example
all balance
Juan Blanco
Jun 18 2018 15:42
var balance = Web3.Web3.Convert.ToWei(100);
            //I have put here 2 in Gwei but it can be anything you want
            var price = Web3.Web3.Convert.ToWei(2, UnitConversion.EthUnit.Gwei);
            var totalAmount = balance - (price * Transaction.DEFAULT_GAS_LIMIT);

            var transactionInput = new TransactionInput()
                From = "YourAccount",
                To = "SSS",
                Value = new HexBigInteger(totalAmount),
                Gas = new HexBigInteger(Transaction.DEFAULT_GAS_LIMIT),
                GasPrice = new HexBigInteger(price),
that is your transaction input
and then
var web3 = new Web3.Web3(new Account("privatekey"), url);
  var txn = web3.TransactionManager.SendTransactionAsync(transactionInput);
Michael Ilchuk
Jun 18 2018 15:50
You use Transaction.DEFAULT_GAS_LIMIT
When I estimate gas , it's value > DEFAULT_GAS_LIMIT
i can get exception, when use default value
I need writen "0x" + transactionEncoded ?
or without "0x"
Jun 18 2018 19:39
Hi! How can i check is any string is valid ethereum address?
Stef Heyenrath
Jun 18 2018 19:42

@wtlab You cannot really do that. There are some regular-expression checks and checksums which you can apply.

See for an example.

Jun 18 2018 20:30
@StefH Yeah! That is!) Thanks!!!