Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit 0aaee52

Browse files
committed
cw-tutorial events review changes
1 parent 3a507f7 commit 0aaee52

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/pages/tutorial/cw-contract/event.mdx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { Tabs } from "nextra/components";
22

33
# Events attributes and data
44

5-
The only way our contract can communicate to the world, for now, is by queries. Smart contracts are
6-
passive - they cannot invoke any action by themselves. They can do it only as a reaction to a call.
7-
But if you tried playing with [`wasmd`](https://github.com/CosmWasm/wasmd), you know that execution
8-
on the blockchain can return some metadata.
5+
The only way our contract can communicate with the world, for now, is through queries. Smart
6+
contracts are passive - they cannot invoke any action by themselves. They can do it only as a
7+
reaction to a call. But if you've ever tried playing with
8+
[`wasmd`](https://github.com/CosmWasm/wasmd), you know that execution on the blockchain can return
9+
some metadata.
910

1011
There are two things the contract can return to the caller: events and data. Events are something
1112
produced by almost every real-life smart contract. In contrast, data is rarely used, designed for
@@ -257,17 +258,17 @@ mod tests {
257258
As you can see, testing events on a simple test made it clunky. First of all, every event is heavily
258259
string-based - a lack of type control makes writing such tests difficult. Also, event types are
259260
prefixed with "wasm-" - it may not be a huge problem, but it doesn't clarify verification. But the
260-
problem is, how layered events structure are, which makes verifying them tricky. Also, the "wasm"
261-
event is particularly tricky, as it contains an implied attribute - `_contract_addr` containing an
262-
address called a contract. My general rule is - do not test emitted events unless some logic depends
263-
on them.
261+
problem is how layered the structure of events is, which makes verifying them tricky. Also, the
262+
"wasm" event is particularly tricky, as it contains an implied attribute - `_contract_addr`
263+
containing the address that called the contract. My general rule is - do not test emitted events
264+
unless some logic depends on them.
264265

265266
## Data
266267

267268
Besides events, any smart contract execution may produce a `data` object. In contrast to events,
268-
`data` can be structured. It makes it a way better choice to perform any communication logic relies
269-
on. On the other hand, it turns out it is very rarely helpful outside of contract-to-contract
270-
communication. Data is always only one single object on the response, which is set using the
269+
`data` can be structured. It makes it a way better choice to perform any communication the logic
270+
relies on. On the other hand, it turns out it is very rarely helpful outside of contract-to-contract
271+
communication. Data is always a singular object within the response, and it's set with the
271272
[`set_data`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Response.html#method.set_data)
272273
function. Because of its low usefulness in a single contract environment, we will not spend time on
273274
it right now - an example of it will be covered later when contract-to-contract communication will

0 commit comments

Comments
 (0)