Contract Events
EventEmitter contract
contract EventEmitter =
datatype event =
FirstEvent(int)
| AnotherEvent(indexed address, string)
entrypoint emitEvents(value: int, msg: string) =
Chain.event(FirstEvent(value))
Chain.event(AnotherEvent(Call.caller, msg))Decode events using ACI
// events emitted by contract calls are automatically decoded
const tx = await contract.emitEvents(1337, 'this message is not indexed');
console.log(tx.decodedEvents);
/*
[
{
name: 'AnotherEvent',
args: [
'fUq2NesPXcYZ1CcqBcGC3StpdnQw3iVxMA3YSeCNAwfN4myQk',
'this message is not indexed'
],
contract: {
name: 'EventEmitter',
address: 'ct_6y3N9KqQb74QsvR9NrESyhWeLNiA9aJgJ7ua8CvsTuGot6uzh'
}
},
{
name: 'FirstEvent',
args: [1337n],
contract: {
name: 'EventEmitter',
address: 'ct_6y3N9KqQb74QsvR9NrESyhWeLNiA9aJgJ7ua8CvsTuGot6uzh'
}
}
]
*/Last updated
Was this helpful?