8

For example:

enum Stages {
    AcceptingBookings,
    StopAcceptingBookings,
    Finished
}

Stages public stage = Stages.AcceptingBookings;
function rand ( uint256 param) atStage(Stages.AcceptingBookings) returns (uint256){}

In the above, when the contract is in state 'Stages.AcceptingBookings' only code within that function will run, pretty cool..

I just need to be able to access it via web3.eth though and I cant see clear explanation. If anyone knows please let me know I want to check what stage I am at from web3.eth if it is possible.

The above code is from the Solidity docs on State Machine: https://solidity.readthedocs.org/en/latest/common-patterns.html#state-machine

Works great from geth, just trying to work out the syntax for web3.eth

  • I see various uses of web.eth and web3.eth, can you please make them all the same thing if that's what you meant? – linagee Feb 10 '16 at 21:51
  • please fix the title to more generic, e.g. "How do I access member variables of a contract from web3" – Paul S Feb 10 '16 at 23:26
7

public members of Solidity contracts have an automatic getter method created, it would look something like this:

contractInstance.stage(callback)

For general API on contract methods see See Calling Contract Methods Docs

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.