Decorators overview
ask! provides a set of decorators to allow developers to code smart contract in Assemblyscirpt. eg.@contract
. To further define the decorator's behavior during compilation, ask! introduces parameters within decorator. eg. @message({"mutates": false})
. Currently, ask! has mainly two types of decorators: class decorators and syntax decorators.
#
contract#
class:@contract
: marks this class as a contract
@dynamic: marks this class as an existing contract for cross contract call
#
property:@state
: marks this class property as state needs to be synced to blockchain
#
method:@constructor
: marks this method as constructor in instatiate a contract
@message
: marks this method as a public method in a smart contract
#
event#
class@event
: marks this class as an event emitted during contract execution
#
property:@topic
: marks this class property as a topic and to be indexed
#
metadata@doc
: provide documentation for the information generated by metadata.json. It can add documentation comments for @contract/@event/@message/@constructor declarations.
@contract@doc(desc = "MyToken conract that implement erc20 contract")class MyToken { // ...}