0

I am facing some issue in executing the eth.sendTransaction method. Though there is sufficient amount of balance in the transferring account, I am still getting insufficient funds error. I've tried passing a hexadecimal number to the value field of the abc object, but it still doesn't work.

eth.sendTransaction works fine when the from account is set to eth.accounts[0], for any other account, it throws this error.

enter image description here

1 Answer 1

5

Because there is no enough balance for your balance, cost consists of value and transaction fee(gasPrice * gasLimit). So you must deposite some ether or mine to send transaction. When sending transaction, your local node would valid transaction, you can learn more by reading source code. Error declare:

// ErrInsufficientFunds is returned if the total cost of executing a transaction
// is higher than the balance of the user's account.
ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value")

and the valid transaction logic as follows:

// validateTx checks whether a transaction is valid according to the consensus
// rules and adheres to some heuristic limits of the local node (price and size).
func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
    // Heuristic limit, reject transactions over 32KB to prevent DOS attacks
    if tx.Size() > 32*1024 {
        return ErrOversizedData
    }
    // Transactions can't be negative. This may never happen using RLP decoded
    // transactions but may occur if you create a transaction using the RPC.
    if tx.Value().Sign() < 0 {
        return ErrNegativeValue
    }
    // Ensure the transaction doesn't exceed the current block limit gas.
    if pool.blockChain.GasLimit().Cmp(tx.Gas()) < 0 {
        return ErrGasLimit
    }
    // Make sure the transaction is signed properly
    from, err := types.Sender(pool.signer, tx)
    if err != nil {
        return ErrInvalidSender
    }
    // Drop non-local transactions under our own minimal accepted gas price
    local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network
    if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {
        return ErrUnderpriced
    }
    // Ensure the transaction adheres to nonce ordering
    currentState, err := pool.blockChain.State()
    if err != nil {
        return err
    }
    if currentState.GetNonce(from) > tx.Nonce() {
        return ErrNonceTooLow
    }
    // Transactor should have enough funds to cover the costs
    // cost == V + GP * GL
    if currentState.GetBalance(from).Cmp(tx.Cost()) < 0 {
        return ErrInsufficientFunds
    }
    intrGas := IntrinsicGas(tx.Data(), tx.To() == nil, pool.homestead)
    if tx.Gas().Cmp(intrGas) < 0 {
        return ErrIntrinsicGas
    }
    return nil
}

Hope it helps~

4
  • But the balance, as it seen from the console, is much more than what I am trying to transfer. Insufficient funds error is seen even if I try to transfer a single ether. i.e. "abc = {from: eth.accounts[1], to: eth.accounts[2], value: 1}" yields the same error. Commented Sep 6, 2017 at 5:12
  • You din't understand cost == V + GP * GL. For your situation, V is 1, ethereum gasPrice default is 18000000000, transaction gasLimit is 21000, so the `cost = 1 + 18000000000 * 21000', it's far out of your balance. Commented Sep 6, 2017 at 5:36
  • Okay. Then what can be the reason behind transfer from eth.accounts[0] to any other account work just fine? Commented Sep 6, 2017 at 6:02
  • If you would send transaction, your account must have enough balance, this cost includes transaction_value and transaction_fee. Commented Sep 6, 2017 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.