Check stateful annotations
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
This commit is contained in:
@@ -4,7 +4,7 @@ contract BasicAuth =
|
||||
|
||||
function init() = { nonce = 1, owner = Call.caller }
|
||||
|
||||
function authorize(n : int, s : signature) : bool =
|
||||
stateful function authorize(n : int, s : signature) : bool =
|
||||
require(n >= state.nonce, "Nonce too low")
|
||||
require(n =< state.nonce, "Nonce too high")
|
||||
put(state{ nonce = n + 1 })
|
||||
|
||||
Reference in New Issue
Block a user