I set up a private blockchain and it works. I tried a very simple contract, it was mined successfully, but the state variables are not saved in the blockchain or this is what it seems. The getter functions returns no value.

What is wrong here?

The contract code:

pragma solidity ^0.4.0;

contract MyContract{
uint constant value = 90;
string constant mystr = "Hello";

function getValue() constant returns(uint){
    return value;

function getMystr() constant returns(string){
    return mystr;

The result in solidity browser (run offline, web3 provider connected to localhost:8545):

enter image description here

  • 1
    I test everything is ok. did you start rpc and connect http://localhost:8545? Aug 21 '17 at 13:39
  • Yes. It is connected, the contract is mined. I see the message in solidity browser: Waiting for transaction to be mined..., after that I start mining in geth console: miner.start() and it is mined.
    – Dany D
    Aug 21 '17 at 13:53
  • It's so weird. I'm sure that the state variables are saved. do you change Environment from Web3 provider to JavaScript VM to try it ? Aug 21 '17 at 14:15
  • try to desactivate all the other plugins
    – Badr Bellaj
    Aug 22 '17 at 0:31

I tried exactly the same and it gave the correct values as follow.

enter image description here

Apparently there's nothing you are doing wrong. What I can only suggest is give it a try toggling between Web3 provider and JavaScript VM and select again the web3 provider and try deploying the contract again.

  • 1
    Somehow it worked. I think the problem was with the provider. It should be web3. Thank you.
    – Dany D
    Aug 24 '17 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.