Skip to content

Edit Events and Core Events articles #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions docs/language/core-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ title: Core Events
sidebar_position: 22
---

Core events are events emitted directly from the FVM (Flow Virtual Machine).
The events have the same name on all networks and do not follow the standard naming (they have no address).
Core events are events emitted directly from the Flow Virtual Machine (FVM). The events have the same name on all networks and do not follow the standard naming (they have no address).

Refer to the [public key section](./crypto.mdx#public-keys) for more details on the information provided for account key events.
Refer to the [public key section] for more details on the information provided for account key events.

### Account Created

Expand Down Expand Up @@ -148,9 +147,11 @@ event InboxValuePublished(provider: Address, recipient: Address, name: String, t
| `name` | `String` | The name associated with the published value |
| `type` | `Type` | The type of the published value |

To reduce the potential for spam,
we recommend that user agents that display events do not display this event as-is to their users,
and allow users to restrict whom they see events from.
:::tip

To reduce the potential for spam, we recommend that user agents that display events do not display this event as-is to their users, and allow users to restrict whom they see events from.

:::

### Inbox Value Unpublished

Expand All @@ -168,9 +169,11 @@ event InboxValueUnpublished(provider: Address, name: String)
| `provider` | `Address` | The address of the publishing account |
| `name` | `String` | The name associated with the published value |

To reduce the potential for spam,
we recommend that user agents that display events do not display this event as-is to their users,
and allow users to restrict whom they see events from.
:::tip

To reduce the potential for spam, we recommend that user agents that display events do not display this event as-is to their users, and allow users to restrict whom they see events from.

:::

### Inbox Value Claimed

Expand All @@ -189,6 +192,12 @@ event InboxValueClaimed(provider: Address, recipient: Address, name: String)
| `recipient` | `Address` | The address of the claiming recipient |
| `name` | `String` | The name associated with the published value |

To reduce the potential for spam,
we recommend that user agents that display events do not display this event as-is to their users,
and allow users to restrict whom they see events from.
:::tip

To reduce the potential for spam, we recommend that user agents that display events do not display this event as-is to their users, and allow users to restrict whom they see events from.

:::

<!-- Relative links. Will not render on the page -->

[public key section]: ./crypto.mdx#public-keys
32 changes: 16 additions & 16 deletions docs/language/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@ sidebar_position: 21

Events are special values that can be emitted during the execution of a program.

An event type can be declared with the `event` keyword.
An event type can be declared with the `event` keyword:

```cadence
event FooEvent(x: Int, y: Int)
```

The syntax of an event declaration is similar to that of
a [function declaration](./functions.mdx#function-declarations);
events contain named parameters, each of which has an optional argument label.
The syntax of an event declaration is similar to that of a [function declaration]; events contain named parameters, each of which has an optional argument label.

Event parameters may only have a valid event parameter type.
Valid types are boolean, string, integer, arrays and dictionaries of these types,
and structures where all fields have a valid event parameter type.
Resource types are not allowed, because when a resource is used as an argument, it is moved.
Event parameters may only have a valid event parameter type. Valid types are boolean, string, integer, arrays, and dictionaries of these types, and structures where all fields have a valid event parameter type. Resource types are not allowed, because when a resource is used as an argument, it is moved.

Events can only be declared within a [contract](./contracts.mdx) body.
Events cannot be declared globally or within resource or struct types.
Events can only be declared within a [contract] body. Events cannot be declared globally or within resource or struct types.

```cadence
// Invalid: An event cannot be declared globally
Expand All @@ -39,10 +33,9 @@ contract Events {
//
event ResourceEvent(resourceField: @Vault)
}

```

### Emitting events
## Emitting events

To emit an event from a program, use the `emit` statement:

Expand All @@ -65,10 +58,17 @@ contract Events {
}
```

Emitting events has the following restrictions:
Please note the following restrictions when emitting events:

- Events can only be invoked in an `emit` statement. This means events cannot be assigned to variables or used as function parameters.
- Events can only be emitted from the location in which they are declared. You can not emit an event from an imported contract from a contract that imports it.

### Destroy events

- Events can only be invoked in an `emit` statement.
It's possible to specify a special event to be automatically emitted when a resource is destroyed. See [destroying events] for more information.

This means events cannot be assigned to variables or used as function parameters.
<!-- Relative links. Will not render on the page -->

- Events can only be emitted from the location in which they are declared.
[function declaration]: ./functions.mdx#function-declarations
[contract]: ./contracts.mdx
[destroying events]: ./resources.mdx#destroy-events