geth で sendTransaction 時に balance が不足していると Error: insufficient funds for gas * price + value が発生する

Sat, May 11, 2019 - 2 min read

geth で sendTransaction (送金) するときに balance (残高) が不足していると、Error: insufficient funds for gas * price + value が発生することを動作確認した手順をご紹介します。

Ethereum | イーサリアム

前提条件

本サイトの geth (go-ethereum) をインストールしてプライベートネットワークに接続する手順 [MacOS 編] で geth のインストールとプライベートネットワークへの接続まで完了している前提で進めます。

geth balance 不足時の挙動確認

geth console で残高不足時の送金エラーを動作確認したコードは以下の通りです。

> 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

まとめ

  • Error: insufficient funds for gas * price + value が発生する
  • balance がマイナスになることは無い

以上、geth で残高不足のときのエラーの挙動を確認したい、現場からお送りしました。

参考情報