---
title: "4. Events, Metadata, and Royalties"
url: "https://radix.wiki/developers/scrypto/04-events-metadata-royalties"
version: "1.2.2"
updated: 2026-08-19
last_verified: 2026-07-27
license: CC-BY-4.0
license_url: "https://creativecommons.org/licenses/by/4.0/"
---

# 4. Events, Metadata, and Royalties

## Events

Components can emit [events](https://docs.radixdlt.com/docs/scrypto-events/) during transaction execution. Events are encoded in [SBOR](https://docs.radixdlt.com/docs/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](/contents/tech/core-protocols/transaction-manifests) or the `radix-event-stream` library for real-time indexing.

## Entity Metadata

[Metadata](/contents/tech/core-concepts/metadata-module) 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](/contents/tech/core-concepts/metadata-module) to display assets consistently.

### Setting Metadata at Creation

```rust
ResourceBuilder::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](/contents/tech/core-concepts/component-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.

## Next Steps

- [Testing Scrypto Blueprints](/developers/scrypto/05-testing-scrypto) – move from poking at resim by hand to tests that run in CI

## External Links

- [Events documentation](https://docs.radixdlt.com/docs/scrypto-events/)
- [Metadata documentation](https://docs.radixdlt.com/docs/metadata)
- [Metadata Standards](/contents/tech/core-concepts/metadata-module)
- [Royalties documentation](/contents/tech/core-concepts/component-royalties)
