concept command in category blockchain
appears as: commds, commd, commds, The commds

This is an excerpt from Manning's book Blockchain in Action.
contract Counter { int value; //positive value counter constructor() public{ value = 0; } modifier checkIfLessThanValue(int n) { #1 require (n <= value, 'Counter cannot become negative'); _; } modifier checkIfNegative(int n) { #1 require (n > 0, 'Value must be greater than zero'); _; } function get() view public returns (int){ return value; } function initialize (int n) checkIfNegative(n) public { #2 value = n; } function increment (int n) public checkIfNegative(n) { #2 value = value + n; } function decrement (int n) public checkIfNegative(n) #2 checkIfLessThanValue(n) { value = value - n; } }
You’ll need a Ropsten account address and seed mnemonic to restore this account (chapter 8). Save the 256-bit account number and the mnemonic in a file (such as DCCEnv.txt) for use during deployment and interaction.