sophia/test/contracts/simple_storage.aes
Ulf Norell 5aed8b3ef5 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
2019-05-13 13:39:17 +02:00

29 lines
578 B
Plaintext

/* Example from Solidity by Example
http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html
The Solidity code:
contract SimpleStorage {
uint storedData
function set(uint x) {
storedData = x
}
function get() constant returns (uint) {
return storedData
}
}
*/
contract SimpleStorage =
record state = { data : int }
function init(value : int) : state = { data = value }
function get() : int = state.data
stateful function set(value : int) =
put(state{data = value})