Skip to Content

Watching contract activity over RPC

Focus: one typed fire_rpc_event payload that off-chain clients can watch through daemon WebSocket contract_event notifications.

Open in Playground 

rpc_notice.slx
struct RpcNotice { message: string } entry notify(message: string) { fire_rpc_event(90, RpcNotice { message }) return 0 }

How it works

  • RpcNotice is a dedicated RPC struct, so clients receive named fields instead of a positional any[].
  • notify(message) is the only contract entry in this example.
  • fire_rpc_event(90, RpcNotice { message }) produces a daemon WebSocket contract_event notification.

Subscribe once to daemon RPC method subscribe with notify set to contract_event. The notification contains the contract hash, the event id 90, and the encoded RpcNotice data.

Useful event names for contract development:

  • contract_deploy: a contract was deployed.
  • contract_invoke: a contract entry was invoked.
  • contract_event: a contract called fire_rpc_event.
  • contract_transfers: a contract transferred assets.
  • new_asset: a new asset was created.
Last updated on