Interaction
deploy logicname.EndpointName(calldata) Runs the deploy function and prints the output with an interaction hash. If persistent state is present, the deployer should be run beforehand.
deploy estore2.Init2()
Execution Complete! [133 FUEL] [0xebe7f4006790e171b89e6fa2ff4ec8bcc5250fb0a530ac1ddcc7c9e72c08ae5b]
invoke logicname.EndpointName(calldata) Runs the Invoke function and prints the output with and interaction hash.
invoke estore2.GetName()
Execution Complete! [301 FUEL] [0x527ab0b72da1ac2bcf888128998d1f63a1fabe11b9b898265073ef1ae7db247c]
Execution Outputs ||| name:akash
enlist logicname.EndpointName(calldata) Runs the enlist function and prints the output with an interaction hash. The sender needs to be configured beforehand. If ephemeral state is present, the enlist function must be included.
enlist estore2.EnL(name: "akash", supply: 999)
Execution Complete! [337 FUEL] [0xa445656f5fea0b2592a1b87d9b50be1a122eda29dce44c7d7b5f7ff24d01c3ff]
Execution Outputs |||
The Deployer and Enlister can each be used only once in a contract, similar to a constructor linked to the sender's address. When both are present, the Deployer must run first. After the Enlister is used, only invoke calls are allowed.
Invoke as a different sender
The sender in an interaction, started by invoke is always the default sender, defined using set default.sender command.
But to quickly invoke an endpoint as some other user, we can use the keyword as like this
register robert
invoke F.Flip() as robert
The endpoint will be invoked with a different sender, we can pick any registered user for a sender, it can be specified by name or by their identifier 0xabcd....
Defining participants and their access levels
By default, Cocolab invokes any endpoint with all registered users as participants in the interactions and all grant write access to their data. If we want to restrict this, we can use with keyword with invokeand specify participants and optionally their access levels (write, read or none).
E.g., in our context-aware flipper we can try restricting access to a user's storage.
register robert
F.Flip() as robert
(this succeeds)
F.Flip() as robert with robert/read
error: unable to store bool: slot is read-only
If we specify any participant using with, only the listed participants will be actors in the interaction. If we don't use with, all registered users will be participants.