Coco supports persistent and ephemeral state types. Persistent state is the state of the module and ephemeral state refers to the state of the participant.
endpoint deployer SeedSupply!()
In modules having a persistent state, it is necessary to have a deployer endpoint to initialize this state. The ‘!’ sign at the end of a endpoint denotes that it performs a stateful change.
ERC20.State.name
In this the dot is used to access the state of the module followed by the name of the field.
Enlisters will be used to initialize the ephemeral state similar to deployers that initialize the persistent state.
ephemeral state is not currently supported in cocolang v0.1.2
coco TokenLedger
state persistent:
name String
symbol String
supply U64
balances Map[Address]U64
endpoint deployer Init!(name String, symbol String):
mutate name -> TokenLEdger.State.name
mutate symbol -> TokenLEdger.State.symbol
endpoint deployer SeedSupply!(name String, symbol String, supply U64, seed Address):
mutate name -> TokenLEdger.State.name
mutate symbol -> TokenLEdger.State.symbol
mutate supply -> TokenLEdger.State.supply
mutate balances <- TokenLEdger.State.balances:
balances[seed] = supp