Events
Smart Contract Events#
Event Option#
Events in aelf smart contracts are used to represent occurrences during execution. These events are logged in the transaction traces.
Example of an event definition:
1message Transferred {2option (aelf.is_event) = true;3aelf.Address from = 1 [(aelf.is_indexed) = true];4aelf.Address to = 2 [(aelf.is_indexed) = true];5string symbol = 3 [(aelf.is_indexed) = true];6sint64 amount = 4;7string memo = 5;8}
To trigger this event in a contract:
1Context.Fire(new Transferred()2{3From = from,4To = to,5...6});
External code can monitor this event after the transaction execution.
Edited on: 15 July 2024 03:27:19 GMT+0