You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Docs/Articles/CasperEventStandard.md
+14-57Lines changed: 14 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
1
1
# Casper Event Standard (CES)
2
2
3
-
The **Casper Event Standard (CES)** is a convention adopted by make-software for emitting and consuming typed events from Casper smart contracts. Contracts that follow CES store a self-describing schema alongside their events, making it possible to decode any event without out-of-band knowledge of its structure.
3
+
The **Casper Event Standard (CES)** is a convention adopted by contract developers for emitting and consuming typed events from Casper smart contracts. Contracts that follow CES store a self-describing schema alongside their events, making it possible to decode any event without out-of-band knowledge of its structure.
4
4
5
5
The Casper .NET SDK provides the `Casper.Network.SDK.CES` namespace with three classes: `CESContractSchema` (schema loading and parsing), `CESEvent` (event parsing and field access), and `CESParser` (scanning execution results).
6
6
7
7
---
8
8
9
9
## How CES Works
10
10
11
-
A CES-compliant contract uses two special named keys:
11
+
A CES-compliant contract uses two special named keys for events:
12
12
13
-
| Named key |CLType |Purpose |
13
+
| Named key | Purpose |
14
14
|---|---|---|
15
-
|`__events_schema`|`Any`|Binary-encoded schema listing every event type and its fields |
16
-
|`__events`|`Map(U32, Bytes)`|Ordered map of event index → raw event bytes |
15
+
|`__events_schema`| Binary-encoded schema listing every event type and its fields |
16
+
|`__events`| Ordered map of event index → raw event bytes |
All integers are little-endian. The `String` encoding used here is the standard Casper string encoding: a `u32` length followed by the UTF-8 content (no null terminator).
32
+
The `String` encoding used here is the standard Casper string encoding: a `u32` length followed by the UTF-8 content (no null terminator).
33
33
34
34
### Events (`__events`)
35
35
@@ -42,39 +42,7 @@ for each field (in schema order):
42
42
raw field bytes — native Casper serialization, no CLValue wrapper
43
43
```
44
44
45
-
The `"event_"` prefix is stripped internally when looking up the event in the schema, but `CESEvent.Name` preserves the original name exactly as stored in the bytes.
46
-
47
-
### CLType Binary Encoding
48
-
49
-
CLType tags used in the schema are single bytes:
50
-
51
-
| CLType | Tag |
52
-
|---|---|
53
-
|`Bool`|`0x00`|
54
-
|`I32`|`0x01`|
55
-
|`I64`|`0x02`|
56
-
|`U8`|`0x03`|
57
-
|`U32`|`0x04`|
58
-
|`U64`|`0x05`|
59
-
|`U128`|`0x06`|
60
-
|`U256`|`0x07`|
61
-
|`U512`|`0x08`|
62
-
|`Unit`|`0x09`|
63
-
|`String`|`0x0a`|
64
-
|`Key`|`0x0b`|
65
-
|`URef`|`0x0c`|
66
-
|`Option`|`0x0d` + inner type |
67
-
|`List`|`0x0e` + item type |
68
-
|`ByteArray`|`0x0f` + `u32` size |
69
-
|`Result`|`0x10` + ok type + err type |
70
-
|`Map`|`0x11` + key type + value type |
71
-
|`Tuple1`|`0x12` + type₁ |
72
-
|`Tuple2`|`0x13` + type₁ + type₂ |
73
-
|`Tuple3`|`0x14` + type₁ + type₂ + type₃ |
74
-
|`Any`|`0x15`|
75
-
|`PublicKey`|`0x16`|
76
-
77
-
Compound types (Option, List, Map, etc.) are encoded recursively — the tag is followed immediately by its inner type tags.
45
+
The `"event_"` prefix is stripped automatically when parsing the event raw bytes.
-`CESEvent.Name` always reflects the exact string found in the event bytes, including the `"event_"` prefix. Schema lookup normalises the name by stripping that prefix automatically.
285
-
- The `Vec<u8>` outer length prefix is auto-detected and skipped transparently by `ParseEvent`.
286
-
-`EventsURef` access rights are ignored when matching the dictionary seed — only the 32-byte hash is compared.
287
-
- Both legacy (`ContractPackage`/`Contract`) and Casper 2.x (`Package`/`AddressableEntity`) contract models are supported throughout `LoadAsync`.
288
-
-`LoadAsync` accepts either a contract-package hash or a direct contract hash. If the value starts with `"contract-"` it is used as-is and package resolution is skipped; `ContractPackageHash` will be `null` in the resulting schema.
289
-
- Schemas loaded via `ParseSchema` directly (not through `LoadAsync`) have `SchemaURef` and `EventsURef` set to `null` and cannot be used with `GetEvents`.
0 commit comments