Last active
June 19, 2018 21:08
-
-
Save tomclose/c5a4f3f897ca6e121ee86911959de6fe 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
*.sol linguist-language=Solidity |
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
import "fmg-core/contracts/State.sol"; | |
contract PaymentGame { | |
using State for bytes; | |
// The core State library contains all attributes needed for a payment game state! | |
function validTransition(bytes _old, bytes _new) public pure returns (bool) { | |
uint[] oldResolution = State.resolution(_old); | |
uint[] newResolution = State.resolution(_new); | |
// conserve total balance | |
require(oldResolution[0] + oldResolution[1] == newResolution[0] + newResolution[1]) | |
// can't take someone else's funds by moving | |
uint8 i = _new.indexOfMover(); | |
require(newResolution[i] <= oldResolution[i]); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment