Management API Reference

Ecosystem wallet

Create a game in Unity

To make these instructions concrete, we have created a sample ecosystem wallet called Rapidfire ID. To interact with it, you can find its SDK in the NPM package directory: @rapidfire/id.

You can check out the GitHub repository for Rapidfire Wallet to learn how to create your own wallet.

This guide will walk you through adding support for any ecosystem wallet into a Unity app by integrating the Mobile Wallet Protocol.

TARGET PLATFORM VS UNITY EDITOR PLATFORM

We have added compilation flags to the Unity SDK to ensure that specific Unity editors can only build certain platform targets. Please note that the table below indicates which editor you can use to build a platform target, but it does not determine whether you can run the SDK in that editor.

For example, the SDK allows you to build iOS games using a macOS Unity Editor, but you cannot use the Windows Unity Editor.

Target PlatformWindows Unity EditormacOS Unity Editor
Windows
macOS
Android
iOS
WebComing soonComing soon

If you need a template or scaffold to start with, you can check out the Ecosystem Wallet Unity Example.

Setup#

Install Mobile Wallet Protocol Client#

There are two ways to install the SDK:

  1. Open the Package Manager
  2. Click the add + button and select "Add package from git URL..." Enter https://github.com/openfort-xyz/mobile-wallet-protocol-unity-client?path=com.openfort.mobile-wallet-protocol and click 'Add'

Usage#

Mobile Wallet Protocol Client provides 2 interfaces for mobile app to interact with the Smart Wallet, an EIP-1193 compliant provider interface.

Option 1: EIP-1193 Provider#

Create a new EIP1193Provider instance, which is EIP-1193 compliant.

ClientController.cs

_54
using UnityEngine;
_54
using MobileWalletProtocol;
_54
_54
public class ClientController : MonoBehaviour
_54
{
_54
[SerializeField]
_54
MWPClientOptions m_Options = new MWPClientOptions()
_54
{
_54
Metadata = new AppMetadata()
_54
{
_54
Name = "Smart Wallet",
_54
CustomScheme = "exp://"
_54
},
_54
Wallet = Wallet.CreateWebWallet(
_54
name: "Rapid fire wallet",
_54
scheme: "https://id.sample.openfort.xyz#policy=pol_a909d815-9b6c-40b2-9f6c-e93505281137",
_54
iconUrl: "https://purple-magnificent-bat-958.mypinata.cloud/ipfs/QmfQrh2BiCzugFauYF9Weu9SFddsVh9qV82uw43cxH8UDV"
_54
)
_54
};
_54
_54
MWPClient m_Client;
_54
string m_Account;
_54
_54
void Awake()
_54
{
_54
m_Client = new MWPClient(m_Options);
_54
}
_54
_54
public async void RequestAccounts()
_54
{
_54
var result = await m_Client.EthRequestAccounts();
_54
_54
if (result.IsSuccess)
_54
{
_54
var accounts = result.Value;
_54
_54
m_Account = accounts[0];
_54
_54
foreach (var account in accounts)
_54
{
_54
Debug.Log("Account: " + account);
_54
}
_54
}
_54
else
_54
{
_54
Debug.LogError("Error: " + result.Error);
_54
}
_54
}
_54
_54
public void Disconnect()
_54
{
_54
m_Client.Reset();
_54
}
_54
}

Gas Sponsorship#

If you want to sponsor transactions, you need to add #policy=POLICY_ID to the wallet scheme.


_10
#policy=POLICY_ID