Treasure Connect brings user-fiendly 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.

Integraters can choose from a variety of authentication methods, including email, phone number, social sign-ins, or EOA wallet via MetaMask or WalletConnect.

Treasure Connect

Treasure Banner

Public members

public async Task<ChainId> GetChainId();
public string Email;
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);


See Assets/Treasure/Example/Scripts for usage examples
using Treasure;

// Query connected wallet status

// Show/hide the Treasure Connect UI

// Retrieve current chain id
var chainId = await TDK.Connect.GetChainId();

// Change connected chain (Recommend using TDK.Identity.StartUserSession to ensure the user has valid user session)

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

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


See Assets/Treasure/Example/Scripts for usage examples
// Start a user session
var authToken = await StartUserSession(ChainId.TreasureRuby);

// Validate user session
var authedUser = await ValidateUserSession(ChainId.TreasureRuby, authToken);