events.gno

0.87 Kb ยท 25 lines
 1package emitevents
 2
 3import "std"
 4
 5func Render(_ string) string {
 6	out := "# Emitting events in Gno\n\n"
 7
 8	out += `Emitting events in blockchain systems is one of the ways to make off-chain life easier.
 9To emit an event, simply use the **Emit()** function found in the **std** package.
10
11This function takes in string arguments as follows:
12
13`
14	out += "```\nstd.Emit(\"EventName\", \"key1\", \"value1\", \"key2\", \"value2\")\n```\n"
15	out += "The function takes in a variadic number of key:value pairs after the event name.\n\n"
16	out += "Events are stored in block results, and can be listened to via the [tx-indexer](https://github.com/gnolang/tx-indexer).\n\n"
17
18	out += "Click [here](/r/docs/events$help&func=Emit&CustomEventValue=) to submit a transaction that will emit an event."
19
20	return out
21}
22
23func Emit(CustomEventValue string) {
24	std.Emit("ExampleEvent", "key", CustomEventValue)
25}