---
title: "4. Events, Metadata, and Royalties"
path: "/developers/scrypto/04-events-metadata-royalties"
version: "1.1.0"
author: "Hydrate"
createdAt: "2026-02-22T17:46:02.571Z"
updatedAt: "2026-03-16T18:21:35.819Z"
---

# 4. Events, Metadata, and Royalties

<Infobox>
| **Events, Metadata, and Royalties** |
| Difficulty | Intermediate |
| Est. Time | 20 minutes |
| Prerequisites | [Scrypto Fundamentals](/developers/scrypto/01-fundamentals) |
| Language | [Scrypto](/developers/legacy-docs/updates/roadmap/scrypto/scrypto) (Rust) |
| Official Docs | [Events](https://docs.radixdlt.com/docs/events) |
</Infobox>

## Events

Components can emit [events](https://docs.radixdlt.com/docs/events) during transaction execution. Events are encoded in [SBOR](/contents/tech/core-concepts/sbor) and stored in the transaction receipt — useful for indexing, analytics, and off-chain reactions.

```rust
#[derive(ScryptoSbor, ScryptoEvent)]
pub struct SwapEvent {
    pub input_amount: Decimal,
    pub output_amount: Decimal,
    pub pool_address: ComponentAddress,
}

// Inside a method:
Runtime::emit_event(SwapEvent {
    input_amount: dec!("100"),
    output_amount: dec!("95.5"),
    pool_address: self_address,
});
```
Events appear in [Gateway API](/developers/infrastructure/02-radix-apis) responses and can be decoded using the [Radix Engine Toolkit](/developers/legacy-docs/integrate/radix-engine-toolkit/radix-engine-toolkit) or the `radix-event-stream` library for real-time indexing.

## Entity Metadata

[Metadata](/developers/legacy-docs/reference/radix-engine/metadata/metadata) is a key-value store available on all entities — resources, components, packages, and accounts. The [Radix Wallet](/contents/tech/core-protocols/radix-wallet) and other clients use [standardized keys](https://docs.radixdlt.com/docs/metadata-standards) to display assets consistently.

### Setting Metadata at Creation

```rust
[ResourceBuilder](https://docs.radixdlt.com/docs/resources-and-data)::new_fungible(OwnerRole::None)
    .metadata(metadata!(
        init {
            "name" => "My Token", locked;     // Cannot be changed
            "symbol" => "MYT", locked;
            "description" => "A token", updatable;  // Can be updated
            "icon_url" => Url::of("https://example.com/icon.png"), locked;
        }
    ))
    .mint_initial_supply(1000);
```
### Standard Metadata Keys

| Key | Used By | Purpose |
| --- | --- | --- |
| `name` | Wallet, Dashboard | Human-readable name |
| `symbol` | Wallet | Short ticker (e.g., XRD) |
| `description` | Dashboard | Brief description |
| `icon_url` | Wallet | Token icon image |
| `info_url` | Dashboard | Project website |

Keys are strings (max 100 chars). You can add custom keys beyond the standard set — clients will display them as-is.

## Royalties

Radix has a built-in [royalty system](https://docs.radixdlt.com/docs/royalties) that lets developers earn XRD whenever their [blueprints](https://docs.radixdlt.com/docs/blueprints-and-components) or components are used. Royalties are collected automatically as part of transaction fees — users see the total cost upfront.

### Package Royalties

Set royalties on specific functions or methods when publishing a package:

```rust
#[blueprint]
#[types(/* ... */)]
mod my_dex {
    enable_package_royalties! {
        instantiate => Free;
        swap => Xrd(1.into());  // 1 XRD per swap call
    }

    // ...
}
```
### Component Royalties

Component instantiators can also set per-method royalties at instantiation time. The total royalty for a transaction is the sum of all package and component royalties for every method called.

Pricing strategy

You can specify royalties as a fixed XRD amount or an approximate USD equivalent. Use USD-equivalent pricing for stable fee expectations regardless of XRD price fluctuations.

## External Links

- [Events documentation](https://docs.radixdlt.com/docs/events)
- [Metadata documentation](https://docs.radixdlt.com/docs/metadata)
- [Metadata Standards](/developers/legacy-docs/reference/standards/metadata-standards/metadata-standards)
- [Royalties documentation](https://docs.radixdlt.com/docs/royalties)