# PLUS Game SDK for Unity (preview v0.1.0) Adds PLUS Mainnet (EVM chain ID 88088) to a Unity game. Unity 2020.3 or newer. ## Install Copy the `PlusGame` folder into your project's `Assets` folder. ``` Assets/PlusGame/Runtime/PlusGame.cs C# API (namespace PlusMainnet) Assets/PlusGame/Plugins/WebGL/PlusGame.jslib WebGL bridge to plus-game-sdk.js Assets/PlusGame/Samples/PlusGameExample.cs Example MonoBehaviour ``` ## What works where | Call | WebGL | Windows / macOS / Android / iOS | |---|---|---| | `GetBalance(address)` | ✅ | ✅ (JSON-RPC to rpc.plusmain.net) | | `Checkout(invoiceId)` | ✅ in-page checkout | ✅ opens PLUS Pay in the browser and waits for payment | | `GetInvoice(invoiceId)` | ✅ | ✅ | | `Connect()`, `SignIn()`, `SendPlus()` | ✅ (browser wallet) | ❌ throws `WEBGL_ONLY` | On native builds, sign players in on your web page (Sign-In with PLUS) and link the account to your game server. ## Usage ```csharp using PlusMainnet; string plus = await PlusGame.GetBalance("0x..."); // WebGL: wallet sign-in. Send session.token to YOUR server, which checks it with // GET https://plusmain.net/api/game/auth/session (Authorization: Bearer ). var session = await PlusGame.SignIn("Sign in to My Game"); // Purchases: your SERVER creates the invoice with its PLUS Pay API key, the game only gets the id. var result = await PlusGame.Checkout(invoiceId); // result.status == "paid" ``` Errors are `PlusGame.PlusGameException` with a `Code`: `EXPIRED`, `CLOSED`, `TIMEOUT`, `WEBGL_ONLY`, `BAD_ADDRESS`, `BAD_INVOICE`, `NETWORK`, or the wallet's code (`4001` = the player cancelled). ## Rules - Never put a PLUS Pay API key in the game client. - Grant items on your server only, after the signed `invoice.paid` webhook. A paid result in the client is a hint for the UI. - WebGL: browsers block popups that are not opened from a click. If the checkout window is blocked, the SDK opens it on the player's next click or tap. - Gambling games and paid random items for PLUS are not allowed. Rewards and tradable items need a review per country: https://plusmain.net/developers/games/apply Docs: https://plusmain.net/developers/games · This is a preview: test with small amounts.