LoginSignup
3
0

More than 3 years have passed since last update.

[go-ethereum]Transaction送信時に「Returned error: insufficient funds for gas * price + value」が発生する

Posted at

記事の内容

gethを使ってTransaction送信の動作確認を行っている際に「Returned error: insufficient funds for gas * price + value」というエラーが発生
かなりハマってしまったので対応内容をメモとして残します。

環境

geth:v1.9.8-stable-d62e9b28/linux-amd64/go1.13.3

参考サイト

Ethereum入門

エラーの原因(insufficient funds for gas * price + value)

このエラーの原因ですが、「geth init」時に指定するgenesis.json内のchainIdとgeth起動時の「--networkid」が異なる状態でTransactionの送信を行うと発生する様です。

そこで、genesis.jsonと起動コマンドを確認しました。

myGenesis.json
{
  "config": {
    "chainId": 1111
  },
  "nonce": "0x0000000000000042",
  "timestamp": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "",
  "gasLimit": "0x8000000",
  "difficulty": "0x4000",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x3333333333333333333333333333333333333333",
  "alloc": {}
}
geth --networkid 1111 --nodiscover --datadir "/home/eth_private_net" console 2>> /home/eth_private_net/geth_err.log

chainIdと--networkidは一緒の値になっていました。
この状態でGeth JavaScript Consoleから送金処理を行っても、txPoolのPendingに溜まったまま処理がされませんでした。

Geth JavaScript ConsoleでchainIdを確認してみます。

> eth.chainId()
"0x0"

"0x0"??
何かがおかしい

genesis.jsonの設定内容

どうもgethの1.4と1.5の間でgenesis.jsonの設定内容が大きく変わった様です。
とりあえず、以下のサイトに載っている内容でgenesis.jsonの設定内容を修正してみます。

Go Ethereum

genesis.json
{
  "config": {
    "chainId": 1111,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "ethash": {}
  },
  "difficulty": "1",
  "gasLimit": "8000000",
  "alloc": {}
}

この内容でgeth initを行い、Transactionの送信を行ったところ無事にTransactionがブロックに取り込まれることを確認出来ました。

> eth.chainId()
"0x457"

chainIdも設定した内容が正しく表示されました。

所感

ブロックチェーンはバージョンのアップデートが頻繁に行われる技術なので最新のモジュールを扱う場合は公式ドキュメントをちゃんと見ないといけないなと教訓を得ました。。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0