Unity SDK

zypp-labs/unity-sdk brings offline-first Web3 intents to Unity game engines — in-game economies, ticket sales, arcade machines, and any interactive experience.

Installation

Add via Unity Package Manager:

https://github.com/zypp-labs/zypp-sdk.git?path=packages/unity-sdk

Requirements

  • Unity 2021.3+
  • iOS 13+ or Android API 21+

Quick Start

using ZyppLabs;

// Create an intent
var intent = ZyppSdk.CreateIntent("move_player", "{\"x\":10}", ZyppTrustTier.Unsigned);
ZyppSdk.MarkProvisional(intent.intentId);
ZyppSdk.Finalize(intent.intentId);

// Settle on-chain
var result = ZyppSdk.Settle(intent.intentId, "https://api.mainnet-beta.solana.com", ZyppExitType.SolanaRpc);

Encrypted Storage

ZyppSdk.InitWithSecureStorage(platformKey);

InitWithSecureStorage and InitWithEncryption are identical at runtime — the difference is naming. InitWithSecureStorage signals the key comes from platform secure storage; InitWithEncryption is the low-level equivalent.

API Reference

MethodDescription
CreateIntent(kind, payload, trustTier)Create and enqueue an intent
CreatePaymentIntent(amount, assetHex, recipientHex)Create a Payment intent
MarkProvisional(intentId)Transition Pending → SyncedProvisional
Finalize(intentId)Transition SyncedProvisional → SyncedFinalized
AttachSignature(intentId, sig, pubKey, nonce)Attach cryptographic envelope
AttachIssuerSignature(intentId, sig, nonce)Attach issuer signature (Ticket)
AttachHolderSignature(intentId, sig)Attach holder signature (Ticket)
GetQueue()Get all queued entries
QueueLength()Get queue length
Settle(intentId, exitUrl, exitType)Settle an intent
SettleWithStrategy(...)Settle with degraded routing
ReportConnectivity(quality)Report network quality
CreateTransferPacket(intentId)Create offline transfer packet
DecodeTransferPacket(packetB64)Decode a transfer packet
InitWithEncryption(key)Initialize encrypted persistence
InitWithSecureStorage(key)Initialize with platform key
RegisterKind(kindJson)Register kind for validation
Lint()Audit trust tier config

All methods throw ZyppException on failure.

Arcade Template

For arcade-style games, use the pre-built templates for common patterns:

// Player buys credits — creates a payment intent
var payment = ZyppSdk.CreatePaymentIntent(1_000_000, wSolMintHex, developerWalletHex);

// Player moves — creates an unsigned action intent
var moveIntent = ZyppSdk.CreateIntent("move_avatar", moveData, ZyppTrustTier.Unsigned);

// Player trades item — requires signed intent
var tradeIntent = ZyppSdk.CreateIntent("trade_item", tradeData, ZyppTrustTier.Signed);

The arcade template enforces trust tier requirements per action kind — high-stakes actions like spend_tokens or trade_item require Signed, while move_avatar and ping can be Unsigned. Violations are rejected with TrustTierTooLow.

Coroutine Support

using System.Collections;
using UnityEngine;

public class IntentHandler : MonoBehaviour
{
    IEnumerator CreateAndSettleIntent()
    {
        var intent = ZyppSdk.CreateIntent("mint_nft", nftPayload, ZyppTrustTier.Signed);
        ZyppSdk.MarkProvisional(intent.intentId);

        // Wait for network
        yield return new WaitForSeconds(1);

        var result = ZyppSdk.Settle(intent.intentId, rpcUrl, ZyppExitType.SolanaRpc);
        if (result.status == "ok")
        {
            ZyppSdk.Finalize(intent.intentId);
            Debug.Log($"Intent finalized: {intent.intentId}");
        }
    }
}

Building from Source

cd Scripts
./build-rust.sh          # all targets
./build-rust.sh ios      # iOS only
./build-rust.sh android  # Android only

Pre-built binaries for macOS are included in Runtime/Plugins/macOS/.

Next Steps