Unity Wallet SDK (Alpha)

The Unity Wallet SDK is used to enhance interoperability across the open metaverse.

For real-time updates on the SDK, please check out our GitHub Repo here.

Overview

The Unity Wallet SDK is a pioneering solution designed to enhance interoperability across the open metaverse.

This SDK enables seamless interoperability across the open metaverse, allowing users to import and interact with 3D digital objects from their wallets into various metaverse platforms and games developed with Unity.

Purpose

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.

Scope

A set of APIs and Web3 wallet integrations that streamline importing 3D digital objects into Unity3D-based applications.

Prerequisites

  • Unity 2022.3.17f or above.

  • IL2CPP managed code stripping level: Minimal (or lower).

Supported Platforms

  • Android

  • iOS

  • macOS

  • Windows

  • WebGL

Getting Started

The Mona Wallet Unity SDK is distributed as a Unity Package.

Download Package

You can download the latest official .unitypackage from the Releases page.

Alternatively, you can download the latest generated package from Build Packages 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.

Install package

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:

  • If you have an existing Web3 integration in your project such as Thirdweb, WalletConnect, etc. Please try using our API-only package instead.

  • The SDK has been tested using Unity 2022 LTS. We highly recommend using 2022 LTS.

  • The Newtonsoft and Nethereums DLLs are included as part of the Unity Package, feel free to deselect them if you already have them installed as a dependency to avoid conflicts.

Monaverse Manager

All you need now is a MonaverseManager prefab present in your scene.

Navigate to Assets > Monaverse > Core > Prefabs > MonaverseManager and drag it into your scene.

Make sure you set the following fields:

  • Mona Application Id: You can get one from Monaverse

  • WalletConnectProjectId: Your project ID for WalletConnect. Get one at Wallet Connect

Core Integration Layers

Web3 Wallet Integration Layer

The Unity Wallet SDK integrates the WalletConnect SDK, offering developers and users the choice from a broad range of supported wallets.

Key functionalities

  • Select Wallet: Users can select from a wide range of compatible Wallet Apps to connect with.

  • Connect: Users can connect their Web3 wallets through WalletConnect-compatible wallets, providing their address for authentication.

  • Sign: Enables users to approve SIWE messages manually via their Wallet App for secure login to the Mona Platform.

This layer manages the connection to the user's Web3 wallet to access public wallet information and perform signature authorization for the Mona platform.

For a full list of all the compatible wallets available check out the following WalletConnect website.

Mona API Layer

The API layer acts as the primary interface for interacting with the Mona platform, providing secure endpoints and features such as:

  • VerifyWallet: Validates a given wallet address and generates a SIWE message for user authentication.

  • Authorize: Accepts a SIWE Message and a Signature to generate an AccessToken for subsequent authenticated API calls. (The signing process happens in the Wallet layer where the User is prompted to approve the signature within their Wallet App)

  • GetCollectibles: Retrieves the authenticated user's collection of 3D NFTs.

  • GetCollectibleById: Fetches a specific collectible by its unique identifier.

Example of how to Authorize a client:

// Step 1: Verify Wallet Address
// Obtain the wallet address via your existing Web3 wallet integration
string walletAddress = "user_wallet_address";

// Validate the connected wallet with Mona
var validateWalletResult = await MonaApi.ApiClient.Auth.ValidateWallet(walletAddress);

// Check if the wallet validation request succeeded
if(!validateWalletResult.IsSuccess)
{
    Debug.LogError($"There was a problem validating your wallet: {validateWalletResult.Message}");
    return;
}

//If the wallet is not registered, ask the user to sign up at <https://monaverse.com>
if (validateWalletResult.Data.Result == ValidateWalletResult.WalletIsNotRegistered)
{
    Debug.LogError("Wallet is not registered. Please sign up at <https://monaverse.com>");
    return;
}

// Step 2: Sign the Message and Authorize
// Sign the SiweMessage using your Web3 wallet integration
// This is the equivalent to a Wallet Personal Sign
var signature = await walletSigner.Sign(validateWalletResult.Data.SiweMessage);

// Authorize with Monaverse using the signed message and the SiweMessage
var authorizationResult = await MonaApi.ApiClient.Auth.Authorize(signature, validateWalletResult.Data.SiweMessage);

if (!authorizationResult.IsSuccess)
{
    Debug.LogError($"Authorization failed.{authorizationResult.Message}");
    return;
}

//Ready to call authorized APIs

Example of Collectible data returned:

{
  "id": "bgsDpasdriLhk",
  "type": "Avatar",
  "checked": false,
  "minted": false,
  "nsfw": false,
  "promoted": false,
  "__v": 11,
  "activeVersion": 0,
  "artist": "John Doe",
  "description": "Test",
  "creator": "0xe42c4fe879955cEa16380e9dAf9E7b6B48126E93",
  "slug": "grifter-squid-goerli",
  "views": 0,
  "accessibility": {
    "accessLevel": "Public",
    "accessibleAt": null,
    "accessibleUntil": null
  },
  "_updated_at": "2024-05-03T18:36:56.258Z",
  "_created_at": "2024-05-03T18:32:35.784Z",
  "_deleted_at": null,
  "collectionId": null,
  "hidden": false,
  "image": "bafasdak2ulwymssqfsaeadls65nt7xxftzh3c3npe7snkmhmfqxqoyu",
  "lastSaleEventId": null,
  "lastSalePrice": null,
  "owner": "0xe42c4fe879955cEa16380e9dAf9E7b6B48126E93",
  "owners": [
    {
      "address": "0xe42c4fe879955cEa16380e9dAf9E7b6B48126E93",
      "amount": 1
    }
  ],
  "parentId": null,
  "price": null,
  "properties": [],
  "traits": {
    "Genre": "Cyber Punk",
    "Season": "Spring"
  },
  "subCollectionId": null,
  "title": "Grifter Squaddie Goerli",
  "nft": {
    "contract": null,
    "ipfsUrl": "bafybeig3tvmgazsdfgadfgsdfm7qrtq2undmaxpsy7xnc7m6flzlgffy",
    "network": null,
    "tokenHash": null,
    "tokenId": null,
    "tokenUri": null,
    "transactionId": null,
    "tokenStandard": null,
    "amount": null
  },
  "creatorId": null,
  "documentId": null,
  "versions": [
    {
      "asset": "<https://cdn-staging.mona.gallery/sdfe5433-suet-d9ik-rrgl-fsdfrww.vrm>"
    }
  ]
}

The API layer is delivered as an independent sub-package that can be used by those developers/projects that already have an Web3 integration (i.e. WalletConnect, MetamaskSDK, ThirdwebSDK, etc)

This API layer can be pulled separately as a sub package from:

https://github.com/monaverse/mona-wallet-unity/tree/main/Assets/Monaverse/Core/Plugins/Mona/com.monaverse.api

User Interface Layer (WIP)

Developers will be equipped with a comprehensive set of screens and views to handle wallet and API tasks:

  • Network selection

  • Wallet Provider Selection

  • Connect and Authorization

  • Collectibles Grid and Detail View

Last updated