Skip to content

Instantly share code, notes, and snippets.

@tomclose
Last active June 19, 2018 21:08
Show Gist options
  • Save tomclose/c5a4f3f897ca6e121ee86911959de6fe to your computer and use it in GitHub Desktop.
Save tomclose/c5a4f3f897ca6e121ee86911959de6fe to your computer and use it in GitHub Desktop.
*.sol linguist-language=Solidity
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