Documentation

Blockus provides a Unity SDK to make it very easy to immediately add wallet support to any Unity game.

Prerequisites

Before you begin with Blockus, you will need to create a game studio and create a project. For API and SDK users, a project API key is required.

  1. Create a Project
  2. Download the Blockus SDK
  3. Import Blockus SDK into your game
  1. Write C# script to call Blockus SDK
    The video shows a simple example of how to connect with Blockus test api. For other services, please check out corresponding documentation.

Example code

using System;  
using System.Collections;  
using System.Collections.Generic;  
using System.Threading.Tasks;  
using UnityEngine;  
using UnityEngine.UI;  
using BlockusSDK;  
using System.Runtime.InteropServices;  
using Newtonsoft.Json;  
using UnityEngine.Diagnostics;  
using System.Numerics;  
using System.Text;

public class ApiStatus : MonoBehaviour  
{  
  public TMPro.TextMeshProUGUI textStatus;  
  // Start is called before the first frame update  
  private Blockus.BlockusSDK \_blockusSDK;

  void Start()  
  {  
      var config = new Blockus.BlockusInitParams()  
      {  
          Project = new Blockus.ProjectConfig()  
          { // Project info is available on project page in Blockus dev portal  
            Id = "<project-id>",  
            Key = "<project-key>",  
          }  
      };  
      _blockusSDK = new Blockus.BlockusSDK(config);  
      textStatus.text = "\< b > Checking connection \</ b >";  
      _ = CheckApiStatus();  
  }

  public async Task CheckApiStatus()  
  {  
      try  
      {  
          var response = await \_blockusSDK.TestApiConnection();  
          textStatus.text = $"\< b >{response}\</ b >";  
          textStatus.color = Color.green;  
      }  
      catch (Exception e)  
      {  
          textStatus.text = $"{e.Message}";  
      }  
  }  
}
  1. Build and run!

Authentication

The Blockus Unity SDK also allows you to manage user login and wallet connections in Unity.

// Login methods supported by unity sdk  
  var response = await blockus.LoginEmail(email, credential);  
  var response = await blockus.LoginGooglePlayGame(email, credential);  
  var response = await blockus.LoginGoogleAccount(email, credential, userId);  
  var response = await blockus.LoginFB(email, credential);  
  var response = await blockus.LoginAppleAccount(email, credential);

Web3 Login

The Blockus Unity SDK also allows you to log in with a web3 wallet in a couple easy steps.

First, add a web3 config in Blockus SDK config:

  void Start()  
  {  
    var config = new Blockus.BlockusInitParams()  
    {  
      Project = new Blockus.ProjectConfig()  
      {  
        Id = "<project-id>",  
        Key = "<project-key>",  
      },  
      Web3 = new Blockus.Web3Config()  
      { // default chain to connect, user can pick other chains in game  
        ChainOrRPC = "goerli",  
      }  
    };  
    _blockusSDK = new Blockus.BlockusSDK(config);  
    _ = login();  
  }

Then simply add the wallet configuration using the prefab component:

Supported chains:

Ethereum
Goerli
Polygon
Mumbai
Arbitrum
ArbitrumGoerli
Binanace
BinanaceTestnet