
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
28 lines
540 B
Plaintext
28 lines
540 B
Plaintext
|
|
contract Remote1 =
|
|
function main : (int) => int
|
|
|
|
contract Remote2 =
|
|
function call : (Remote1, int) => int
|
|
|
|
contract Remote3 =
|
|
function get : () => int
|
|
function tick : () => ()
|
|
|
|
contract RemoteCall =
|
|
|
|
stateful function call(r : Remote1, x : int) : int =
|
|
r.main(gas = 10000, value = 10, x)
|
|
|
|
function staged_call(r1 : Remote1, r2 : Remote2, x : int) =
|
|
r2.call(r1, x)
|
|
|
|
function increment(r3 : Remote3) =
|
|
r3.tick()
|
|
|
|
function get(r3 : Remote3) =
|
|
r3.get()
|
|
|
|
function plus(x, y) = x + y
|
|
|