arrow-left

All pages
gitbookPowered by GitBook
1 of 3

Loading...

Loading...

Loading...

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);
    }
}

Unreal

Unreal integration

Coming soon

Wallets

Integration guide

In order to purchase NFTs the user needs to create a crypto wallet. During wallet creation, the user must provide a password to access the wallet later. It is important to inform the user that the password must be written down or otherwise stored since neither PLAY nor developers can recover the wallet password if forgotten. The NFT virtual items are sold for "" currency.

The wallet creation is handled automatically through the OAuth form based on your game requirement. The user will be prompt to create a wallet if needed when trying to signIn.

rgn-coin