Skip to content

Instantly share code, notes, and snippets.

@vincentlg
Last active July 24, 2017 13:23
Show Gist options
  • Save vincentlg/fa29f578a95dd5453ecec6429e19eec1 to your computer and use it in GitHub Desktop.
Save vincentlg/fa29f578a95dd5453ecec6429e19eec1 to your computer and use it in GitHub Desktop.
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