Treasure Connect brings user-friendly UI components, backed by our Identity service, into your game. It allows users to create and connect their self-custodial wallets to your dApp. Simple and secure.
Developers can choose from a variety of authentication methods, including email and social sign-ins.
Treasure Connect
Public members
Assets/Treasure/TDK/Runtime/Connect/TDK.Connect.cs
public async Task<ChainId> GetChainId();
public string Address;
public async Task<bool> IsWalletConnected();
public void ShowConnectModal();
public void HideConnectModal();
public async Task SetChainId(ChainId chainId);
public async Task Disconnect(bool endSession = false);
Usage
using Treasure;
TDK.Connect.IsWalletConnected();
TDK.Connect.ShowConnectModal();
TDK.Connect.HideConnectModal();
var chainId = await TDK.Connect.GetChainId();
TDK.Connect.SetChainId(ChainId.TreasureTopaz);
Connect status events
The following event hooks are available to track Connect status.
TDK.Connect.OnConnected.AddListener((address) => Debug.Log($"Connected with address: {address}"));
TDK.Connect.OnConnectError.AddListener((exception) => Debug.LogError($"Connect error: {exception.Message}"));
TDK.Connect.OnDisconnected.AddListener(() => Debug.Log("Disconnected"));
Treasure Identity
Public members
Assets/Treasure/TDK/Runtime/Identity/TDK.Identity.cs
public string AuthToken;
public bool IsAuthenticated;
public async Task<User?> ValidateUserSession(ChainId chainId, string authToken);
public async Task<string> StartUserSession(ChainId sessionChainId = ChainId.Unknown, string sessionAuthToken = null);
public async void EndUserSession();
Usage
var authToken = await StartUserSession(ChainId.TreasureTopaz);
var authedUser = await ValidateUserSession(ChainId.TreasureTopaz, authToken);