
Functions must be annotated as `stateful` in order to - Update the contract state (using `put`) - Call `Chain.spend` or other primitive functions that cost tokens - Call an Oracle or AENS function that requires a signature - Make a remote call with a non-zero value - Construct a lambda calling a stateful function It does not need to be stateful to - Read the contract state - Call another contract with value=0, even when the remote function is stateful
10 lines
200 B
Plaintext
10 lines
200 B
Plaintext
|
|
contract Counter =
|
|
|
|
record state = { value : int }
|
|
|
|
function init(val) = { value = val }
|
|
function get() = state.value
|
|
stateful function tick() = put(state{ value = state.value + 1 })
|
|
|