Skip to content

Commit a16d72f

Browse files
corrections to documentation.
Signed-off-by: David Hernando <david.hernando@make.services>
1 parent 83dce82 commit a16d72f

1 file changed

Lines changed: 14 additions & 57 deletions

File tree

Docs/Articles/CasperEventStandard.md

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Casper Event Standard (CES)
22

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.
44

55
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).
66

77
---
88

99
## How CES Works
1010

11-
A CES-compliant contract uses two special named keys:
11+
A CES-compliant contract uses two special named keys for events:
1212

13-
| Named key | CLType | Purpose |
13+
| Named key | Purpose |
1414
|---|---|---|
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 |
1717

1818
### Schema (`__events_schema`)
1919

@@ -29,7 +29,7 @@ for each event:
2929
CLType bytes — Casper binary type encoding (tag byte + optional inner types)
3030
```
3131

32-
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).
3333

3434
### Events (`__events`)
3535

@@ -42,39 +42,7 @@ for each field (in schema order):
4242
raw field bytes — native Casper serialization, no CLValue wrapper
4343
```
4444

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.
7846

7947
---
8048

@@ -109,12 +77,12 @@ CESContractSchema schema = await CESContractSchema.LoadAsync(
10977

11078
The returned `CESContractSchema` is fully annotated:
11179

112-
| Property | Description |
113-
|---|---|
114-
| `Events` | Dictionary of event name → `CESEventSchema` |
115-
| `ContractHash` | Hash of the resolved (or supplied) contract version |
116-
| `ContractPackageHash` | Package hash passed in, or `null` when a direct contract hash was supplied |
117-
| `SchemaURef` | URef of the `__events_schema` named key |
80+
| Property | Description |
81+
|---|------------------------------------------------------------------|
82+
| `Events` | Dictionary of event name → `CESEventSchema` |
83+
| `ContractHash` | Hash of the resolved (or supplied) contract version |
84+
| `ContractPackageHash` | Package hash passed in. May be `null` when a direct contract hash was supplied. |
85+
| `SchemaURef` | URef of the `__events_schema` named key |
11886
| `EventsURef` | URef of the `__events` named key (used when scanning transforms) |
11987

12088
Both legacy (Casper 1.x) and Casper 2.x contract models are supported automatically.
@@ -243,7 +211,7 @@ using System.Text.Json;
243211
using Casper.Network.SDK;
244212
using Casper.Network.SDK.CES;
245213

246-
var client = new NetCasperClient("https://rpc.testnet.casperlabs.io/rpc");
214+
var client = new NetCasperClient("https://node.testnet.casper.network/rpc");
247215

248216
// Load the schema for each contract to watch
249217
var minterSchema = await CESContractSchema.LoadAsync(
@@ -276,14 +244,3 @@ if (buyEvent != null)
276244
var json = JsonSerializer.Serialize(events);
277245
Console.WriteLine(json);
278246
```
279-
280-
---
281-
282-
## Notes
283-
284-
- `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

Comments
 (0)