Solidity

Solidity 和 Web3js 程式碼在私有乙太坊(geth)網路中無法執行,但相同的程式碼在公共乙太坊中執行

  • August 21, 2019
geth version : 1.9.0-stable-52f24617,
node version : v10.16.3,
npm version  : 6.9.0,
web3 version : -- web3@1.0.0-beta.36.

創世紀.json:

{
"config": {
"chainId": 9663080,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"Ethash": {
 "period": 15,
 "epoch": 30000
}
},
"nonce": "0x0",
"timestamp": "0x5d5769ad",
"gasLimit": "0x7FFFFFFFFFFFF",
"difficulty": "0x1",
"mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
"0x02731Eb61f258C104F1BB4191cF715d8D1014CD3": {
 "balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
  1. 在 geth 中,智能合約的部署正在執行,而在呼叫功能時我遇到了一些問題。

2.web3 程式碼和solidity 程式碼都在公共乙太坊中執行,但相同的程式碼在私有網路(geth)中不起作用。

  1. 我的 geth 或 genesis.json 有什麼問題嗎?

Web3js 錯誤:

   Error: Returned values aren't valid, did it run Out of Gas?
at ABICoder.decodeParameters (/home/nithin/project/ConnectedVehicles/node_modules/web3-eth-abi/src/index.js:226:15)
at Contract._decodeMethodReturn (/home/nithin/project/ConnectedVehicles/node_modules/web3-eth-contract/src/index.js:465:22)
at Method.outputFormatter (/home/nithin/project/ConnectedVehicles/node_modules/web3-eth-contract/src/index.js:818:46)
at Method.formatOutput (/home/nithin/project/ConnectedVehicles/node_modules/web3-core-method/src/index.js:163:54)
at sendTxCallback (/home/nithin/project/ConnectedVehicles/node_modules/web3-core-method/src/index.js:473:33)
at /home/nithin/project/ConnectedVehicles/node_modules/web3-core-requestmanager/src/index.js:147:9
at XMLHttpRequest.request.onreadystatechange (/home/nithin/project/ConnectedVehicles/node_modules/web3-providers-http/src/index.js:91:13)
at XMLHttpRequestEventTarget.dispatchEvent (/home/nithin/project/ConnectedVehicles/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
at XMLHttpRequest._setReadyState (/home/nithin/project/ConnectedVehicles/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
at XMLHttpRequest._onHttpResponseEnd (/home/nithin/project/ConnectedVehicles/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
at IncomingMessage.<anonymous> (/home/nithin/project/ConnectedVehicles/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)

我從混音連接到私有(geth),並部署了智能合約和(1),而呼叫功能數據沒有到來。(2)在hash列中,顯示call+transaction hash

混音狀態欄

我改變了 genesis.json 現在它正在工作

{
"config": {
"chainId": 9663080,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5d5cdc87",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x80000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"0x0000000000000000000000000000000000000000": {
 "balance": "0x1"
},
"0x0000000000000000000000000000000000000001": {
 "balance": "0x1"
},
"0x0000000000000000000000000000000000000002": {
 "balance": "0x1"
},
"0x0000000000000000000000000000000000000003": {
 "balance": "0x1"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": 
"0x0000000000000000000000000000000000000000000000000000000000000000"
}

引用自:https://ethereum.stackexchange.com/questions/73410