> For the complete documentation index, see [llms.txt](https://lionstudios.gitbook.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lionstudios.gitbook.io/readme/analytics/api/events/economy.md).

# Economy

| Name           | Type                        | Select   | Backend name     | Description                                                   |
| -------------- | --------------------------- | -------- | ---------------- | ------------------------------------------------------------- |
| transaction    | Transaction                 | Required | transaction      | The Transaction object containing the data of the transaction |
| placement      | string                      | Optional | placement        | The location in the app where the purchase was made           |
| additionalData | Dictionary\<string, object> | Optional | additional\_data | Any additional information                                    |

## Override #1

The player bought, sold or exchanged something in the game

| Name            | Type                        | Select   | Backend name       | Description                                         |
| --------------- | --------------------------- | -------- | ------------------ | --------------------------------------------------- |
| transactionName | string                      | Required | purchase\_name     | Name of the purchase/pack the user bought           |
| spent           | Product                     | Required | spent\_products    | What products the user spent on                     |
| received        | Product                     | Required | received\_products | The user receives the product                       |
| placement       | string                      | Optional | placement          | The location in the app where the purchase was made |
| additionalData  | Dictionary\<string, object> | Optional | additional\_data   | Any additional information                          |

## Code examples:

#### Example-1: When something received

```csharp
// Build Product object
Product productReceived = new Product
{
    virtualCurrencies = new List<VirtualCurrency>
    {
        // virtualCurrencyName: "coin", virtualCurrencyType: "soft", virtualCurrencyAmount: 5
        new VirtualCurrency("coin", "soft", 5)
    },
    items = new List<Item>() // none
    // realCurrency = null (not used)
};
// Transaction Object with productReceived
Transaction transactionN = new Transaction(
    name : "claim_daily_reward_0",
    spent: null,
    received : productReceived,
    productID : null,
    transactionID : null);
// Missiondata can be added inside AdditionData
Dictionary<string, object> additionalData = new Dictionary<string, object>
{
    { "mission_data", new Dictionary<string, object>
        {
            { "mission_type", "main" },
            { "mission_name", "main_" },
            { "mission_id", 2 },
            { "mission_attempt", 10},
        }
    }
};
LionAnalytics.Economy(
    transaction: transaction,
    placement: "daily_reward_screen",
    additionalData: additionalData);
```

#### **Example-2: When something spent**

```csharp
// Build Product object
Product productSpent = new Product
{
    virtualCurrencies = new List<VirtualCurrency>
    {
        // virtualCurrencyName: "hammer", virtualCurrencyType: "meta", virtualCurrencyAmount: 7
        new VirtualCurrency("hammer", "meta", 7)
    },
    items = new List<Item>() // none
    // realCurrency = null (not used)
};
// Transaction Object with productSpent
Transaction transactionN = new Transaction(
    name : "pick_town_person",
    spent: productSpent,
    received : null,
    productID : null,
    transactionID : null);
// Missiondata can be added inside AdditionData
Dictionary<string, object> additionalData = new Dictionary<string, object>
{
    { "mission_data", new Dictionary<string, object>
        {
            { "mission_type", "main" },
            { "mission_name", "main_" },
            { "mission_id", 2 },
            { "mission_attempt", 10},
        }
    }
};
LionAnalytics.Economy(
    transaction: transaction,
    placement: "meta_area_screen",
    additionalData: additionalData);
```

#### **Example-3: When something spent and in return soemthing is received**

```csharp
// Build Product object
Product productReceived = new Product
{
    items = new List<Item>
    {
        // itemName: "ask_witness", itemType: "power_up", itemAmount: 1
        new Item("ask_witness", "power_up", 1)
    },
    virtualCurrencies = new List<VirtualCurrency>() // none
};
Product productSpent = new Product
{
    virtualCurrencies = new List&lt;VirtualCurrency&gt;
    {
        // virtualCurrencyName: "coin", virtualCurrencyType: "soft", virtualCurrencyAmount: 50
        new VirtualCurrency("coin", "soft", 50)
    },
    items = new List&lt;Item&gt;() // none
    // realCurrency = null (not used)
};
// Transaction Object
Transaction transactionN = new Transaction(
    name : "ask_witness",
    spent: productSpent,
    received : productReceived,
    productID : null,
    transactionID : null);
// Missiondata can be added inside AdditionData
Dictionary&lt;string, object&gt; additionalData = new Dictionary&lt;string, object&gt;
{
    { "mission_data", new Dictionary&lt;string, object&gt;
        {
            { "mission_type", "main" },
            { "mission_name", "main_" },
            { "mission_id", 2 },
            { "mission_attempt", 10},
        }
    }
};
LionAnalytics.Economy(
    transaction: transaction,
    placement: "ask_witness",
    additionalData: additionalData);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://lionstudios.gitbook.io/readme/analytics/api/events/economy.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
