Modules
Starting a new Coco module is as simple as typing coco
and the name of your module. Module can be a single file or in multiple files, that all have the same coco <module_name
> header, the files just have to reside in the same folder. In coco Adder
, Adder is the module name.
The Module Superglobal
The name of the module is one of Coco’s superglobals. It can be used to access the state information of the module as well as other information about the logic module.
In the NumberStore
module, the mutate value -> NumberStore.State.value
statement is using the module superglobal to access the module state and mutate it with some value.
Packages
packages are not currently supported yet in cocolang v0.4.0
coco Adder
func Add(x, y U64) -> (z U64):
return {z: x + y}
coco NumberStore
state persistent:
value U64
endpoint deployer persistent Init(value U64):
mutate value -> NumberStore.State.value
endpoint invokable LogicAddress() -> (addr Address):
yield addr Address(NumberStore)