一种以太坊固体方法无法正常工作出现错误返回值无效,是否用完了气体 [英] One of ethereum solidity methods is not working properly got error Returned values aren't valid, did it run Out of Gas

查看:666
本文介绍了一种以太坊固体方法无法正常工作出现错误返回值无效,是否用完了气体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在我的私有以太坊网络上部署一个Solidity程序.但是,当我调用一个方法时,它无法正常工作.

I'm trying to deploy a solidity program to my private ethereum network. However, when i call a method it's not working properly.

这是我在调用方法之前所做的事情.

This is what i'vd done before the call method.

$ truffle console
truffle(development)> var dApp
undefined
truffle(development)> Hello.deployed().then(function(instance) { dApp = instance; })
undefined
truffle(development)> dApp.message.call()

测试环境低于

truffle@5.0.28
solc@0.5.10
linux centOS 7
geth@1.8.23

我尝试了所有解决方案,以解决以下有关堆栈溢出的错误,但这没有用.

I tried all of the solution in answer about the below error in stack overflow, but it didn't work.

奇怪的是,我使用相同的发行版本在macOS上安装了geth,但是其版本与我在centOS上安装的版本不同.在macOS上为1.8.27,在centOS 7上为1.8.23.

Weird thing is that I installed geth on my macos using same release version, but its version was different from what I've installed on my centOS. It's 1.8.27 on macos and 1.8.23 on centOS 7.

顺便说一句,当我在macOS上尝试相同的进度时,它运行良好. 它的返回值在下面.

By the way, it was working well when I tried same progress on my macos. Its return is below.

truffle(development)> dApp.message.call()
'Hello, World : This is a Solidity Smart ' +
  'Contract on the Private Ethereum ' +
  'Blockchain'

Bammmmmmmmmmmm.

Bammmmmmmmmmmm.

下面是我部署的一个稳定程序.

This below is a solidity program I deploied.

pragma solidity >=0.4.15 <0.6.0;
contract Hello {
   string public message;

   function HelloEth() public {
    message = "Hello, World : This is a Solidity Smart Contract on the Private Ethereum Blockchain";
   }
}

这是返回的错误.

Thrown:
Error: Returned values aren't valid, did it run Out of Gas?
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:318:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:208:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-providers-http/src/index.js:96:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:112:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3-core-requestmanager/src/index.js:147:1
    at sendTxCallback (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/~/web3-core-method/src/index.js:473:1)
    at Method.formatOutput (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/~/web3-core-method/src/index.js:163:1)
    at Method.outputFormatter (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/src/index.js:818:1)
    at Contract._decodeMethodReturn (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/src/index.js:465:1)
    at ABICoder.decodeParameters (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/src/index.jsa:226:1)

我真的很想知道,因为我尝试了将近1个月...如果您有任何想法或解决方案,请告诉我. :(

I really want to know because i tried almost 1 months... if you have any idea or any solution please let me know. :(

推荐答案

我也遇到了类似的问题,当我在Geth Github中发布该问题后,他们表示该问题可能是由最新的Solidity编译器(取决于功能)引起的在君士坦丁堡引入.

I also ran into a similar problem, after I posted it in Geth Github, they indicated that the problem may be caused by the latest Solidity compilers which depend on features introduced in Constantinople.

因此,您可能需要在genesis.json中添加"constantinopleBlock": 0,以让您的私有区块链识别您使用的实体版本.

Thus, you might need to add "constantinopleBlock": 0 in your genesis.json to let your private blockchain identify what solidity version you used.

"config": {
    "chainId": 1515,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "clique": {
      "period": 2,
      "epoch": 30000
    }
  },...

希望这个答案可以为您提供帮助.

Hope this answer can help you.

这篇关于一种以太坊固体方法无法正常工作出现错误返回值无效,是否用完了气体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆