Enable your users to connect their Web3 wallets to the open metaverse, allowing them to import and interact with their 3D NFTs within your Unity-based games and applications using our SDK.
- Unity 2022.3.17f or above.
- IL2CPP managed code stripping level: Minimal (or lower).
- Android
- iOS
- macOS
- Windows
- WebGL
The Mona Wallet Unity SDK is distributed as a Unity Package.
You can download the latest official .unitypackage
from the Releases page.
Alternatively, you can download the latest generated package from Main Workflow workflow page. The file is available at the bottom of each workflow run as monaverse-sdk-package
. Please note that this version may not be stable.
Drag and drop the .unitypackage
file into your Unity project or double click it. Feel free to deselect common packages like Newtonsoft if you already have them.
If there are no compiler errors in the console, you are all set!
Important Notes:
- The SDK has been tested using Unity 2022 LTS. We highly recommend using 2022 LTS.
- The Newtonsoft DLLs are included as part of the Unity Package, feel free to deselect/remove them if you already have them installed as a dependency to avoid conflicts.
It's the simplest and most minimal way to interact with the 3D tokens from your wallets, enabled by the Monaverse platform.
- Install the SDK following the steps described above.
- Drag and drop the MonaverseModal prefab to the first scene in your game.
- Enter your
monaApplicationId
in theMonaverseManager
inspector. You can get on at MonaStudio - Open the modal at any time after
Awake
From your code, use this to open the modal.
MonaverseModal.Open();
You can configure the behavior of the modal using optional parameters that control how the modal behaves when opened. This is done by passing a lambda expression to the Open method, which allows you to set various options.
- LoadTokensView: Set to false if you don't want to load the tokens UI after authentication. Default: true
MonaverseModal.Open(options =>
{
options.LoadTokensView = false;
});
- TokenFilter: An optional filter function used to determine which tokens are compatible with your application. Default: null (No filtering)
MonaverseModal.Open(options =>
{
options.TokenFilter = token => token.Kind == "erc1155";
});
You can combine multiple options to customize the behavior further:
MonaverseModal.Open(options =>
{
options.LoadTokensView = false;
options.TokenFilter = token => token.Kind == "erc1155";
});
The MonaverseModal
will take the user through various views in order to authenticate with the Monaverse platform.
Once authentication is granted, the user will have access to their tokens and be able to interact with them from your application.
To generate an OTP, users must provide their email address. The process varies based on their registration status:
- Registered Users: An OTP will be sent to their email.
- Unregistered Users: Registration instructions will be sent to their email.
Users must enter the OTP sent to their email in the previous step. Upon successful entry, the authentication process is completed, granting access to all authenticated APIs. The next screen, the Tokens View, will then be loaded.
From this view, the user can browse through their tokens.
As a developer, you may signal the SDK on how to identify which tokens are compatible with your application (See the filter function
in the Open Modal
section). Compatible items will have a checkmark on their left hand side.
Displays details of a selected token with Preview
and Import
actions available.
You must tell the SDK how to handle the Import
action via events.
By default, the Preview
action will open the respective webpage to a token's details page in the Monaverse.com
marketplace
The MonaverseModal
class exposes a set of events for you to handle optionally from your code.
This is a sample WebGL application demonstrating how to use the SDK and the Modal
prefab to quickly connect users to their Monaverse account and Tokens.
Demo App
The Source Code for this example is included in the SDK.
Our SDK now supports leaderboards, allowing developers to integrate high-score tracking into their games. Below is a guide on how to enable and use this feature.
-
Enable Leaderboards on the Studio Website:
To enable the leaderboard feature, navigate to your application's page on the MonaStudio site and click onEnable Leaderboards
. Once enabled, additional settings will become available, allowing you to configure thefeatured
leaderboard, which will be the default leaderboard displayed on our website. -
Obtain the SDK Secret:
On the same application page, you'll find theSDK Secret
, which is required to authenticate yourPostScore
requests from Unity.There are two ways to provide the
SDK Secret
in Unity:-
Set it once at startup using:
MonaverseManager.Instance.SDK.SetSecret("YOUR_SDK_SECRET");
-
Optionally, pass it in each score submission call:
var result = await MonaverseManager.Instance.SDK .PostScore(score: 100, topic: "Level 1", sdkSecret: "YOUR_SDK_SECRET"); // Optional
For security reasons, do not store the
SDK Secret
in serialized fields as it is less secure and can be compromised.
-
IMPORTANT: Please do not use the API Secret
in Unity or any other client, as it is intended for server-to-server communication only.
Retrieves the top scores from the leaderboard. You can customize the query to get scores from a specific topic, time period, or sorting order.
var result = await MonaverseManager.Instance.SDK
.GetTopScores(
limit: 20,
offset: 0,
featured: false,
topic: "Level 1",
sortingOrder: "highest",
period: "all_time",
includeAllUserScores: false);
- limit: Maximum number of scores per page (default: 20)
- offset: Start position for scores (default: 0)
- featured: Whether to return scores for the featured leaderboard (ignores topic)
- sortingOrder: Sorting order: "highest" or "lowest"
- topic: Topic of the leaderboard (ignored if featured is true)
- period: Time period: "all_time", "daily", "weekly", or "monthly"
- startTime & endTime: Custom date range for scores
- includeAllUserScores: If true, includes all scores for rank calculation
The response is a GetTopScoresResponse
object containing:
- Items: A list of TopScore records, each representing a score entry.
- Count: Total number of scores returned in this paginated response.
- Id: The unique ID of the score entry.
- User: A TopScoreUser object containing user details.
- Score: The score value achieved by the user.
- Topic: The leaderboard topic the score belongs to.
- CreatedAt: The date and time the score was recorded.
- Rank: The rank of the score in the leaderboard.
- Username: The username of the player.
- Name: The player's display name.
Gets the rank of the authenticated user on a given leaderboard.
var result = await MonaverseManager.Instance.SDK
.GetUserRank(
featured: false,
topic: "Level 1",
sortingOrder: "highest",
period: "all_time",
includeAllUserScores: false);
- featured: If true, retrieves rank for the featured leaderboard set in the MonaStudio website
- sortingOrder: "highest" or "lowest"
- topic: Topic of the leaderboard (ignored if featured is true)
- period: Time period: "all_time", "daily", "weekly", or "monthly"
- startTime & endTime: Custom date range for ranking
- includeAllUserScores: Include all scores for rank calculation
The response is a GetUserRankResponse
object containing:
- Rank: The user's rank in the leaderboard.
- Score: The user's highest score for the given topic and time period.
- Topic: The topic the score was recorded for.
- CreatedAt: The date and time the score was recorded.
Gets scores around the user's rank (Above and below the user)
var result = await MonaverseManager.Instance.SDK
.GetAroundMeScores(
featured: false,
topic: "Level 1",
sortingOrder: "highest",
period: "all_time",
includeAllUserScores: false,
limit: 20);
- featured: If true, retrieves rank for the featured leaderboard
- sortingOrder: "highest" or "lowest"
- topic: Topic of the leaderboard (ignored if featured is true)
- period: Time period: "all_time", "daily", "weekly", or "monthly"
- startTime & endTime: Custom date range for ranking
- includeAllUserScores: Include all scores for rank calculation
A list of TopScore
objects representing scores around the user's rank.
The TopScore
object contains the same fields as described in the GetTopScores
section.
Posts a score to the leaderboard. You can associate the score with a specific topic, or leave it ungrouped by not specifying a topic.
var result = await MonaverseManager.Instance.SDK
.PostScore(score: 20.5f, topic: "Level 1");
NOTE: The SDK secret is required to post scores, you must have set it either in the SetSecret
method at startup or passed as an optional parameter in this call.
var result = await MonaverseManager.Instance.SDK
.PostScore(score: 20.5f,
topic: "Level 1",
sdkSecret: "YOUR_SDK_SECRET"); //Optionally, pass in the SDK secret if not set on startup
- score: The score value to post.
- topic: (Optional) The topic to which the score will be posted, such as "Level 1" or "Halloween Special". If no topic is provided, the score will be posted without a grouping.
- sdkSecret: (Optional) The SDK secret to use for authentication. You can pass it here or set it once at startup using SetSecret().
An ApiResult
object containing:
- IsSuccess: A boolean indicating whether the score was posted successfully.
- Message: A string with additional information about the result. If the request failed, this will contain the error message.
In our leaderboard system, you can use topics to dynamically group scores, making it easy to create multiple leaderboards without explicitly setting up separate ones for each scenario.
A topic is a label you can associate with each score submission. Topics allow you to categorize or group scores under different contexts, such as specific levels, events, or game modes. For example, instead of creating a new leaderboard for every level in your game, you can simply pass a unique topic (e.g., "Level 1"
, "Level 2"
, "Halloween Special"
, etc.) when posting a score. This flexibility allows you to easily manage thousands of different leaderboards dynamically without needing to configure each one manually.
-
Posting Scores: When posting a score using the
PostScore
API, you can specify a topic to group that score under a particular label:var result = await MonaverseManager.Instance.SDK .PostScore(score: _score, topic: "Level 1");
-
Retrieving Scores: When fetching scores with the
GetTopScores
,GetUserRank
, orGetAroundMeScores
APIs, you can query based on the topic to get results specific to that grouping:var topScores = await MonaverseManager.Instance.SDK .GetTopScores(topic: "Level 1");
By leveraging topics, you can create as many dynamic leaderboards as your game requires.
For instance, if your game has thousands of levels, you can track high scores for each level individually by using topics like "Level 1"
, "Level 2"
, and so on. There's no need to manually configure a new leaderboard for each level—topics provide the flexibility to create as many leaderboards as needed, on the fly.
- Topics are case-sensitive, so
"level 1"
and"Level 1"
will be treated as two different topics. Ensure consistency in how you define and reference topics throughout your game. - If no topic is provided when posting a score, the score will not be grouped under any specific topic and will be considered part of the general leaderboard.
By utilizing topics, you gain full control over how scores are organized, allowing your game to scale seamlessly without added complexity.
Our SDK now supports AI-powered generation features, allowing developers to create images and 3D models directly through the Monaverse platform. Below is a guide on how to use these features.
Generates an image from a text description (prompt). The generation is processed asynchronously, and you can monitor its status using GetGenerationRequest.
var result = await MonaverseManager.Instance.SDK
.CreateTextToImageRequest("a bright pink stuffed bunny rabbit");
- prompt: Text description of the image you want to generate
A CreateTextToImageRequestResponse
containing:
- Uuid: Unique identifier for tracking the generation
- Status: Current status of the generation
- InputAsset & OutputAsset: Asset information once generation is complete
Converts a 2D image into a 3D model. Like text-to-image, this is processed asynchronously and can be monitored using GetGenerationRequest.
var result = await MonaverseManager.Instance.SDK
.CreateImageTo3dRequest("your-image-id");
- imageId: ID of the source image to convert to 3D
A CreateImageTo3dRequestResponse
containing:
- Uuid: Unique identifier for tracking the generation
- Status: Current status of the generation
- InputAsset & OutputAsset: Asset information once generation is complete
Retrieves the status and details of a specific generation request.
var result = await MonaverseManager.Instance.SDK
.GetGenerationRequest("generation-request-id");
- requestId: The unique identifier of the generation request
A GetGenerationRequestResponse
containing complete details about the generation request, including:
- Status: Current status (pending, in_progress, completed, failed)
- Input/Output assets
- Creation and completion timestamps
- Error messages if applicable
Retrieves detailed information about a specific asset.
var result = await MonaverseManager.Instance.SDK
.GetAsset("asset-id");
- assetId: The unique identifier of the asset
A GetAssetResponse
containing:
- Creator information
- Source generation details
- Asset metadata (type, URL, creation time)
Retrieves a list of generation requests made by the authenticated user.
var result = await MonaverseManager.Instance.SDK
.GetGenerationRequests(
status: StatusFilter.Completed,
stepType: StepTypeFilter.TextToImage,
limit: 20,
offset: 0
);
- status: Filter by request status (optional)
- stepType: Filter by generation type (optional)
- desiredOutputType: Filter by output type (optional)
- limit: Maximum number of requests to return (default: 100)
- offset: Number of requests to skip (default: 0)
A paginated GetGenerationRequestsResponse
containing:
- Items: List of generation requests
- Count: Total number of requests matching the filters
Retrieves a list of assets owned by the authenticated user.
var result = await MonaverseManager.Instance.SDK
.GetAssets(
assetType: AssetTypeFilter.Image,
limit: 20,
offset: 0
);
- assetType: Filter by asset type (optional)
- limit: Maximum number of assets to return (default: 100)
- offset: Number of assets to skip (default: 0)
A paginated GetAssetsResponse
containing:
- Items: List of assets
- Count: Total number of assets matching the filters
Retrieves the current user's quota information for various generation types.
var result = await MonaverseManager.Instance.SDK
.GetQuota();
A GetQuotaResponse
containing quota information for each generation type:
- Generation type and period
- Usage limits
- Current usage and remaining quota
- Custom quota status
When using the AI generation features, requests go through several states:
- pending: Request is queued for processing
- in_progress: Generation is actively being processed
- completed: Generation has finished successfully
- failed: Generation encountered an error
- awaiting_retry: Generation failed but will be retried automatically
You can monitor the status of any generation request using the GetGenerationRequest
API.