PLAY SDK Documentation
v0.12.0 (Obsolete)
v0.12.0 (Obsolete)
  • 🛠️ENVIRONMENT SETUP
    • Overview
    • PLAY Sample Package
  • 🖥️SDK Integration Guides
    • Getting Started
      • Unity
        • Tech Requirements
        • Step 1 - Import packages
        • Step 2 - Import credentials
        • Step 3 - Environments
        • Step 4 - Initialization
      • Unreal
        • Tech Requirements
        • Step 1 - Import packages
        • Step 2 - Configure credentials
        • Step 3 - Environments
        • Step 4 - Initialization
    • Authentication
      • Unity
      • Unreal
    • User Profile
      • Unity
      • Unreal
    • Virtual Items
      • Unity
      • Unreal
    • Inventory
      • Unity
      • Unreal
    • Store
      • Unity
      • Unreal
    • Currency (IAP)
      • Unity
      • Unreal
    • Achievements
      • Unity
      • Unreal
    • Game Progress
      • Unity
      • Unreal
    • Leaderboards
      • Unity
      • Unreal
    • Matchmaking
      • Unity
      • Unreal
    • Wallets
      • Unity
      • Unreal
    • Analytics
      • Unity
      • Unreal
    • Notifications
      • Unity
      • Unreal
    • Module Requests
  • 🎲Game Design Guides
    • Overview
    • User Authentication
    • User Profile
    • Game (Progression + Rewards)
    • Virtual Items
    • Currency (IAP)
    • Store
    • Inventory
    • Achievements
    • NFT Purchase Flow & Wallets
    • Limited-Time Offers
    • NFT Passes
  • 📌Links
    • PLAY Whitepaper
    • PLAY Postman API Doc
    • PLAY Dev Dashboard
    • PLAY Example Repository Dev
    • PLAY Example Repository Prod
    • Report an Issue
    • Discord dev-chat
    • Telegram Community Channel
    • Social Links
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. SDK Integration Guides
  2. Wallets

Unity

If you are selling an NFT in your game, it is important to check the following :

Is user authenticated with a email?

using UnityEngine;
using RGN;

public class WalletExamples : MonoBehaviour
{
    private bool IsUserAuthenticatedWithEmail()
    {
        return RGNCoreBuilder.I.CurrentAuthState.AuthProvider == EnumAuthProvider.Email;
    }
}

Is user has a wallet?

using UnityEngine;
using RGN;
using RGN.Modules.Wallets;
using System.Threading.Tasks;

public class WalletExamples : MonoBehaviour
{
    private async Task<bool> IsUserHasBlockchainRequirement()
    {
        bool hasRequirement = await WalletsModule.I.IsUserHasBlockchainRequirementAsync();
        return hasRequirement;
    }
}

Create wallet

using UnityEngine;
using RGN.Modules.Wallets;

public class WalletExamples : MonoBehaviour
{
    private void CreateWallet()
    {
        // This will open the OAuth form for the wallet creation
        WalletsModule.I.CreateWallet();
    }
{

Example flow for NFT purchase

using System.Collections.Generic;
using UnityEngine;
using RGN;
using RGN.Modules.Wallets;
using RGN.Modules.SignIn;
using RGN.Modules.Store;

public class WalletExamples : MonoBehaviour
{
    private async void BuyNFTVirtualItem()
    {
        bool authWithEmail = RGNCoreBuilder.I.CurrentAuthState.AuthProvider == EnumAuthProvider.Email;
        if (!authWithEmail)
        {
            EmailSignInModule.I.TryToSignIn();
            return;
        }

        bool hasBlockchainRequirement = await WalletsModule.I.IsUserHasBlockchainRequirementAsync();
        if (!hasBlockchainRequirement)
        {
            WalletsModule.I.CreateWallet();
            return;
        }

        List<string> virtualItemIds = new List<string> { "myNftVirtualItemId" };
        PurchaseResult purchaseResult = await StoreModule.I.BuyVirtualItemsAsync(virtualItemIds);
    }
}

Was this helpful?

🖥️