# Events

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

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

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

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. Types that can be in event definitions are restricted to booleans, strings, integer, and arrays or dictionaries of these types.

Events can only be declared within a contract body. Events cannot be declared globally or within resource or struct types.

Resource argument types are not allowed because when a resource is used as an argument, it is moved. A piece of code would not want to move a resource to emit an event, so it is not allowed as a parameter.

```
// Invalid: An event cannot be declared globally
//
event GlobalEvent(field: Int)

pub contract Events {
    // Event with explicit argument labels
    //
    event BarEvent(labelA fieldA: Int, labelB fieldB: Int)

    // Invalid: A resource type is not allowed to be used
    // because it would be moved and lost
    //
    event ResourceEvent(resourceField: @Vault)
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://max-daunarovich.gitbook.io/flow-network/introduction/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
