# Incentives

**URL:** https://heroiclabs.com/docs/hiro/unity/incentives/
**Summary:** Incentives are a way to drive and increase player retention and engagement in your game.
**Keywords:** incentives, player progression
**Categories:** hiro, unity, incentives

---


# Incentives

Read more about the Incentive system in Hiro [here](../../concepts/incentives/).

## Initializing the incentive system

The incentive system relies on the [Nakama System](../getting-started/nakama-system) and an `ILogger`, both must be passed in as dependencies via the constructor.

```csharp
var incentiveSystem = new IncentiveSystem(logger, nakamaSystem);
systems.Add(incentiveSystem);
```

## Subscribing to changes in the incentive system

You can listen for changes in the incentive system so that you can respond appropriately, such as updating the UI, by implementing the `IObserver` pattern, or use the `SystemObserver<T>` type which handles it for you.

```csharp
var disposer = SystemObserver<IncentiveSystem>.Create(incentiveSystem, system => {
    Instance.Logger.Info($"System updated.");

    // Update UI elements etc as necessary here...
});
```

## Sender incentives

### Listing sender incentives

You can list all sender incentives for the user.

```csharp
var incentivesList = await incentiveSystem.SenderListAsync();
foreach (var incentive in incentivesList)
{
    foreach (var (key, value) in incentive.Claims)
    {
        Debug.Log($"{key} claimed at {value.ClaimTimeSec}.");
    }

    foreach (var userId in incentive.UnclaimedRecipients)
    {
        Debug.Log($"{userId} has not yet claimed.");
    }
}
```

### Creating sender incentives

You can create a sender incentive for the user.

```csharp
var incentiveId = "<incentiveId>";
var incentive = await incentiveSystem.SenderCreateAsync(incentiveId);
Debug.Log($"Created incentive with code: {incentive.Code}");
```

### Claiming sender incentives

You can claim a sender incentive for the user.

```csharp
var incentiveCode = "<incentiveCode>";
var incentive = await incentiveSystem.SenderClaimAsync(incentiveCode);
```

### Deleting sender incentives

You can delete a sender incentive for the user.

```csharp
var incentiveCode = "<incentiveCode>";
await incentiveSystem.SenderDeleteAsync(incentiveCode);
```

## Recipient incentives

### Getting recipient incentives

You can get a recipient incentive for the user.

```csharp
var incentiveCode = "<incentiveCode>";
var incentive = await incentiveSystem.RecipientGetAsync(incentiveCode);
```

### Claiming recipient incentives

You can claim a recipient incentive for the user.

```csharp
var incentiveCode = "<incentiveCode>";
var incentive = await incentiveSystem.RecipientClaimAsync(incentiveCode);
```
