skip to Main Content

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()

test env is below

[email protected]
[email protected]
linux centOS 7
[email protected]

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

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.

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.

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";
   }
}

This is the error returned.

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)

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

2

Answers


  1. All variables which you defined as public it will always becoming a methods. so, you can access/call your public variable as same as calling a method in smart contract.

    Login or Signup to reply.
  2. 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.

    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
        }
      },...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search