Skip to main content

Events

Flow events are special values that are emitted on the network during the execution of a Cadence program and can be observed by off-chain observers.

Events are defined as Cadence code and you should read Cadence documentation to understand how to define them.

Since transactions don’t have return values you can leverage events to broadcast certain changes the transaction caused. Clients listening on Flow networks (apps) can listen to these events being emitted and react.

Screenshot 2023-08-18 at 14.09.33.png

There are two types of events emitted on the Flow network:

  • Core events
  • User-defined events

Events consist of the event name and an optional payload.

Screenshot 2023-08-18 at 13.59.01.png

Core Events

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 same naming as user-defined events (they have no address).

A list of events that are emitted by the Flow network is:

Event NameDescription
flow.AccountCreatedEvent that is emitted when a new account gets created.
flow.AccountKeyAddedEvent that is emitted when a key gets added to an account.
flow.AccountKeyRemovedEvent that is emitted when a key gets removed from an account.
flow.AccountContractAddedEvent that is emitted when a contract gets deployed to an account.
flow.AccountContractUpdatedEvent that is emitted when a contract gets updated on an account.
flow.AccountContractRemovedEvent that is emitted when a contract gets removed from an account.
flow.InboxValuePublishedEvent that is emitted when a Capability is published from an account.
flow.InboxValueUnpublishedEvent that is emitted when a Capability is unpublished from an account.
flow.InboxValueClaimed1Event that is emitted when a Capability is claimed by an account.

For more details on the core events, you can read Cadence reference documentation.

User-defined events

Events that are defined inside contracts and when emitted follow a common naming schema. The schema consists of 4 parts:


_10
A.{contract address}.{contract name}.{event type}

An example event would look like:

Screenshot 2023-08-18 at 14.30.36.png

The first A means the event is originating from a contract, which will always be the case for user-defined events. The contract address as the name implies is the location of a contract deployed on the Flow network. Next, is the name of the contracted event originates from, and last is the event type defined in the contract.

There is an unlimited amount of events that can be defined on Flow, but you should know about the most common ones.

Fungible Token Events

All fungible token contracts, including The FLOW Token contract, use the fungible token standard on Flow. As with any contract, the standard emits events when interacted with. When any fungible token is transferred, standard events are emitted. You can find a lot of details on the events emitted in the Fungible Token documentation.

The most common events are when tokens are transferred which is accomplished with two actions: withdrawing tokens from the payer and depositing tokens in the receiver. Each of those actions has a corresponding event:

Withdraw Tokens

Event name: FungibleToken.Withdrawn


_10
event Withdrawn(type: String,
_10
amount: UFix64,
_10
from: Address?,
_10
fromUUID: UInt64,
_10
withdrawnUUID: UInt64,
_10
balanceAfter: UFix64)

Mainnet event: A.f233dcee88fe0abe.FungibleToken.Withdrawn

Testnet event: A.9a0766d93b6608b7.FungibleToken.Withdrawn

Deposit Tokens


_10
event Deposited(type: String,
_10
amount: UFix64,
_10
to: Address?,
_10
toUUID: UInt64,
_10
depositedUUID: UInt64,
_10
balanceAfter: UFix64)

Event name: FungibleToken.Deposited

Mainnet event: A.f233dcee88fe0abe.FungibleToken.Deposited

Testnet event: A.9a0766d93b6608b7.FungibleToken.Deposited

Fee Events

Since fees are governed by a contract deployed on the Flow network, that contract also emits events when fees are deducted.

Charging fees consists of a couple of steps:

  • Calculate and deduct fees
  • Withdraw Flow tokens from the payer account
  • Deposit Flow tokens to the fees contract

These events are very common since they accommodate all transactions on Flow. Each fee deduction will result in three events: the withdrawal of Flow tokens, the deposit of Flow tokens, and the fee deduction.

An example of fee events:


_24
Events:
_24
- Index: 0
_24
Type: A.f233dcee88fe0abe.FungibleToken.Withdrawn
_24
Tx ID: 1ec90051e3bc74fc36cbd16fc83df08e463dda8f92e8e2193e061f9d41b2ad92
_24
Values:
_24
- type (String): "1654653399040a61.FlowToken.Vault"
_24
- amount (UFix64): 0.00000100
_24
- from (Address?): b30eb2755dca4572
_24
_24
- Index: 1
_24
Type: A.f233dcee88fe0abe.FungibleToken.Deposited
_24
Tx ID: 1ec90051e3bc74fc36cbd16fc83df08e463dda8f92e8e2193e061f9d41b2ad92
_24
Values:
_24
- type (String): "1654653399040a61.FlowToken.Vault"
_24
- amount (UFix64): 0.00000100
_24
- to (Address?): f919ee77447b7497
_24
_24
- Index: 2
_24
Type: A.f919ee77447b7497.FlowFees.FeesDeducted
_24
Tx ID: 1ec90051e3bc74fc36cbd16fc83df08e463dda8f92e8e2193e061f9d41b2ad92
_24
Values:
_24
- amount (UFix64): 0.00000100
_24
- inclusionEffort (UFix64): 1.00000000
_24
- executionEffort (UFix64): 0.00000000