Quick Start
Basic Initialization
Section titled “Basic Initialization”using Byteria.SDK;using UnityEngine;
public class GameInitializer : MonoBehaviour{ void Start() { AlphynSDK.OnInitialized += OnSDKInitialized; // Pass "" as the second argument in production (see note below). AlphynSDK.Initialize(30f, ""); }
private void OnSDKInitialized(bool success, string message) { if (success) { Debug.Log("Alphyn SDK ready!"); CheckSecurityStatus(); } else { Debug.LogError($"SDK init failed: {message}"); } }
private void CheckSecurityStatus() { string scanJson = AlphynSDK.GetScanResult(); ScanResult result = ScanResult.Parse(scanJson);
if (result != null && result.HasThreats()) { Debug.LogWarning($"Threats: {result.GetThreatSummary()}"); } }}Note: The second argument of
Initializeis a development-only debug hash. Always callAlphynSDK.Initialize(30f, "")in production builds. During development you can pass your app’s debug hash from the Alphyn Portal instead of"".
Action Verification
Section titled “Action Verification”using System;using System.Globalization;using Byteria.SDK;using UnityEngine;
public class PaymentHandler : MonoBehaviour{ [Serializable] public class WithdrawalContext { public string amount; public string destination; }
// `userId` is your own identifier for the logged-in user, and EnrollForMfa(userId) must have run // once on this device first. The PIN is optional. See https://docs.byteria.dev/mfa/ public void ProcessWithdrawal(string userId, decimal amount, string destination, char[] pin) { string context = JsonUtility.ToJson(new WithdrawalContext { amount = amount.ToString("0.00", CultureInfo.InvariantCulture), destination = destination, }); string resultJson = AlphynSDK.SignAction(userId, "WITHDRAW", context, pin); var result = ActionVerificationResult.Parse(resultJson);
if (result.success && result.IsTokenValid()) { SendToBackend(result.verificationToken); } else { Debug.LogError($"Verification failed: {result.errorMessage}"); } }}Build the context with JsonUtility and write the amount yourself, as a decimal string formatted with
CultureInfo.InvariantCulture. Interpolating a float into the JSON follows the device’s locale, so
a Turkish, German or French device writes 250,5: the context is no longer JSON and SignAction
refuses it. A float cannot hold most amounts exactly either. Send the same string to your backend, which
compares it with the context the verification token carries.