Skip to Content

Contract events: publisher

Focus: one price publisher entry that emits a contract event for listeners.

Open in Playground 

price_publisher.slx
const PRICE_EVENT: u64 = 100 entry publish_price(symbol: string, price: u64) { emit_event(PRICE_EVENT, [symbol, price]) return 0 }

How it works

  • PRICE_EVENT is the event id that other contracts will subscribe to.
  • emit_event(PRICE_EVENT, [...]) sends positional event data to contract listeners.
  • The same event id and payload shape are used by the listener in the next example.
  • The entry returns the default success exit code after publishing the event.

Deploy this first, then pass its contract hash to the listener in the next example.

Last updated on