Last active
July 24, 2017 13:23
-
-
Save vincentlg/fa29f578a95dd5453ecec6429e19eec1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
contract Campaign { | |
enum States | |
{ | |
inprogress, | |
success, | |
fail | |
} | |
// get the current campaign stage | |
function state() public constant returns (uint256) | |
{ | |
return uint256(States.inprogress); | |
} | |
// if the current state does not equal the expected one, throw | |
modifier atStage(States _expectedState) | |
{ | |
if (state() != uint256(_expectedState)) | |
{ | |
throw; | |
} | |
else | |
{ | |
// continue with state changing operations | |
_; | |
} | |
} | |
// must be at state inprogress | |
function contribute() public atStage(States.inprogress) | |
{ | |
//put your code here | |
} | |
//todo genere other transitions function ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment