geth sendTransaction throws Error: insufficient funds for gas * price + value when balance is insufficient

Tadashi Shigeoka ·  Sat, May 11, 2019

I’ll introduce the procedure for verifying that Error: insufficient funds for gas * price + value occurs when the balance is insufficient during sendTransaction (money transfer) in geth.

Ethereum | イーサリアム

Prerequisites

This assumes completion of geth installation and connection to a private network as covered in geth (go-ethereum) をインストールしてプライベートネットワークに接続する手順 [MacOS 編] on this site.

Verifying geth Behavior When Balance is Insufficient

The code for verifying transfer errors when balance is insufficient in geth console is as follows:

> eth.getBlock(0)
{
  difficulty: 16384,
  extraData: "0x",
  gasLimit: 134217728,
  gasUsed: 0,
  hash: "0x7b2e8be699df0d329cc74a99271ff7720e2875cd2c4dd0b419ec60d1fe7e0432",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x3333333333333333333333333333333333333333",
  mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  nonce: "0x0000000000000042",
  number: 0,
  parentHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  receiptsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 507,
  stateRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  timestamp: 0,
  totalDifficulty: 16384,
  transactions: [],
  transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  uncles: []
}
> 
> eth.accounts
[]
> personal.newAccount("pass0")
"0xf93130ca119e32307e107b2693003320ae397c8e"
> personal.newAccount("pass1")
"0x92cf04133e744ade96af0976d6e37d072c14d632"
> eth.accounts
["0xf93130ca119e32307e107b2693003320ae397c8e", "0x92cf04133e744ade96af0976d6e37d072c14d632"]
> 
> eth.getBalance(eth.accounts[0])
0
> eth.getBalance(eth.accounts[1])
0
> 
> personal.unlockAccount(eth.accounts[0], "pass0")
true
> 
> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(1, "ether")})
Error: insufficient funds for gas * price + value
    at web3.js:3143:20
    at web3.js:6347:15
    at web3.js:5081:36
    at :1:1

Summary

  • Error: insufficient funds for gas * price + value occurs
  • Balance never goes negative

That’s all from the Gemba, where we want to verify the error behavior when balance is insufficient in geth.

Reference Information