diff --git a/src/pages/core/architecture/events.mdx b/src/pages/core/architecture/events.mdx index 997b95ff..cd7c2922 100644 --- a/src/pages/core/architecture/events.mdx +++ b/src/pages/core/architecture/events.mdx @@ -2,6 +2,8 @@ tags: ["core", "architecture"] --- +import { Callout } from "nextra/components"; + # Events CosmWasm can emit @@ -9,6 +11,17 @@ CosmWasm can emit events are stored in the block as metadata, allowing the contract to attach metadata to what exactly happened during execution. + + +Some important details about the keys: + +- Whitespaces will be trimmed (i.e.removed from the begin and end) +- Empty keys (that includes keys only consisting of whitespaces) are not allowed +- Keys _cannot_ start with an underscore (`_`). These types of keys are reserved + for `wasmd` + + + By default CosmWasm emits the `wasm` event to which you can add context like so: ```rust filename="wasm_event.rs" template="core" @@ -22,6 +35,10 @@ As mentioned above, CosmWasm only emits the event `wasm` by default. If you want to emit other events, such as domain-specific events like `user_added`, you can construct a fully custom event and attach it to the response. + + Note that those custom events will be prefixed with `wasm-` by the runtime. + + ```rust filename="custom_event.rs" template="core" let event = Event::new("custom_event") .add_attribute("custom_attribute", "value");