Skip to content

Commit

Permalink
fix: Fix example in emit_events (#1169)
Browse files Browse the repository at this point in the history
* Fix example in emit_events

* Update event example in starknet-events.adoc.
  • Loading branch information
stoobie authored Mar 10, 2024
1 parent 33f8e02 commit 75b08a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,12 @@ To emit custom keys, one should use the low level `emit_event` system call:
----
use starknet::syscalls::emit_event_syscall;
let keys = ArrayTrait::new();
keys.append('key');
keys.append('deposit');
let values = ArrayTrait::new();
values.append(1);
values.append(2);
values.append(3);
let keys = array!['key', 'deposit'];
let values = array![1, 2, 3];
emit_event_syscall(keys, values).unwrap_syscall();
----


The above code emits an event with two keys, the https://www.cairo-lang.org/docs/how_cairo_works/consts.html#short-string-literals[strings] "status" and "deposit" (think of those as identifiers of the event that can be used for indexing) and three data elements 1, 2, 3.
The above code emits an event with two keys, the https://www.cairo-lang.org/docs/how_cairo_works/consts.html#short-string-literals[strings] `key` and `deposit` (think of those as identifiers of the event that can be used for indexing) and three data elements 1, 2, 3.


[TIP]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,12 @@ link:https://github.com/starkware-libs/cairo/blob/cca08c898f0eb3e58797674f20994d
[discrete]
==== Example

The following example emits an event with two keys, the strings `status` and `deposit` and three data elements: `1`, `2`, and `3`.
The following example emits an event with two keys, the strings `key` and `deposit` and three data elements: `1`, `2`, and `3`.

[source,cairo]
----
let keys = ArrayTrait::new();
keys.append('key');
keys.append('deposit');
let values = ArrayTrait::new();
values.append(1);
values.append(2);
values.append(3);
let keys = array!['key', 'deposit'];
let values = array![1, 2, 3];
emit_event_syscall(keys, values).unwrap_syscall();
----

Expand Down

0 comments on commit 75b08a1

Please sign in to comment.