I try to write a contract for the test. There some questions
Where can I find all the interface of the Contract, Chain, Call. Or all the namespaces?
Why the public function main2 can modify state without declare “stateful”? code:
contract Identity =
record state = { amount : int }
public function init(x:int) : state =
{ amount = x }
public stateful function main(test:int) =
put(state{amount=test})
state.amount
public function main2(test:int)=
put(state{amount=test})
state.amount
The concept of stateful is not implemented yet, any function can modify the state in the current compiler version.
You cannot generate a random number, since all nodes have to verify the contract execution a truly random number cannot be generated. Pseudo-random numbers can be achieved for example using a the blockhash of a previous generation, or a standard PRNG algorithm. (In current master there is also String.sha3 that can be used for pseudo randomness.)
Sophia isn’t Solidity, so “just like Solidity” is not a concept But in the current master (what will go into 1.2.0) there is an implementation of events that is quite similar to Solidity. The implementation is described here: protocol/sophia.md at master · aeternity/protocol · GitHub