Emitting ARC-28 Events
To emit ARC-28 events from your smart contract you can use the following syntax.
Algorand Python
Section titled “Algorand Python”@arc4.abimethoddef emit_swapped(self, a: arc4.UInt64, b: arc4.UInt64) -> None: arc4.emit("MyEvent", a, b)OR:
class MyEvent(arc4.Struct): a: arc4.String b: arc4.UInt64
# ...
@arc4.abimethoddef emit_swapped(self, a: arc4.String, b: arc4.UInt64) -> None: arc4.emit(MyEvent(a, b))Algorand TypeScript
Section titled “Algorand TypeScript”Algorand TypeScript uses the same Puya compiler as Algorand Python and has similar syntax for emitting ARC-28 events:
import { Contract, arc4, emit } from '@algorandfoundation/algorand-typescript'
class MyEvent extends arc4.Struct { a: arc4.String b: arc4.UInt64}
class MyContract extends Contract { @arc4.abimethod() emitSwapped(a: arc4.String, b: arc4.UInt64): void { emit(new MyEvent({ a, b })) }}OR with explicit event signature:
@arc4.abimethod()emitSwapped(a: arc4.UInt64, b: arc4.UInt64): void { emit('MyEvent(uint64,uint64)', a, b)}OR with inferred types:
@arc4.abimethod()emitSwapped(a: arc4.UInt64, b: arc4.UInt64): void { emit('MyEvent', a, b)}method "MyEvent(byte[],uint64)"frame_dig 0 // or any other command to put the ARC-4 encoded bytes for the event on the stackconcatlog