We define transactions and events in the model file, a script file that implements these transaction functions. Decorators within comments are used to annotate the functions with metadata required for transaction processing, for example:
/**
* Sample transaction processor function.
* @param {org.example.basic.SampleTransaction} tx The sample transaction instance.
* @transaction
*/
async function sampleTransaction(tx) { // eslint-disable-line no-unused-vars
..
emit(event);
}
In the sampleTransaction function, the @param tag is followed by the resource name of the transaction that triggers the transaction processor function. @transaction marks this function as a transaction processor function.