關於以太坊私有鏈中進行交易時餘額不足的問題處理

最近嘗試在本地搭建私有鏈,進行挖礦及其它操作都顯示正常,包括集羣都沒有問題,但是在進行eth.sendTransaction時,提示餘額不足Error: insufficient funds for gas * price + value
在console中 
web3.fromWei(eth.getBalance(eth.accounts[0]))

725

72


eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1],value:web3.toWei(1,'ether')})
Error: insufficient funds for gas * price + value
在console中 

然後通過嘗試增加gas,及gasPrice參數,data參數,用web3j及jsonRPC進行測試,都是同樣的問題。

初步懷疑是配置的問題,後臺找高手確認分析如下,使用的創世區塊是以太坊官方上面的demo,沒有進行更改
{
"config": {
"chainId": 0,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc": {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "0x0",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}

通過將創世區塊配置文件中的chainId改成一個比較大的值,如1000,再進行測試,問題解決。

最終的創世區塊文件如下:
{
"config": {
"chainId": 1000,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc": {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "0x0",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}

運行時的命令行中指定networkid=chainId,即--networkid 1000

在此非常感謝朋友的幫助。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章