Game Studio Integration Guide
This guide is for game developers who want their web-based game to run smoothly inside super-apps, crypto wallets, and standard browsers using a single API.
1. Installation
Install the core SDK package:
npm install @playsout/hybrid-sdk2. Initialization
Initialize the SDK as early as possible in your app lifecycle.
import { PHSDK } from "@playsout/hybrid-sdk";
// Initialize the SDK
const sdk = await PHSDK.init({
appId: "com.yourstudio.game",
// Configures how to connect if in a Web3 Wallet
injectedProviderKey: "ethereum",
// Used for mapping your in-game items to host billing
pay: {
catalog: {
version: "1.0",
products: {
"100_coins": {
// EVM config
networkId: 137,
token: { address: "0x...", decimals: 6, symbol: "USDT" },
payee: "0x...",
amount: "1000000",
// Entitlement detail
entitlement: { id: "100_coins", type: "consumable", quantity: 1 }
}
}
}
}
});3. Checking Capabilities
Because your game might run in a simple browser (Core capabilities only) or a full super-app (Core + Advanced capabilities), you should always check what the environment supports:
const caps = sdk.runtime.getCapabilities();
if (caps.pay.purchase) {
// Show premium shop UI
renderShopButton();
} else {
// Hide premium features, or provide a web-checkout alternative later
hideShopButton();
}4. Example: Sign In & Purchase
You can build unified flows without caring if the user is in MetaMask or a custom Android Super App.
// 1. Get Identity
if (caps.identity.signIn) {
try {
const identity = await sdk.identity.signIn();
console.log("Logged in as:", identity.subject);
} catch (e) {
console.error("Sign in failed", e);
}
} else {
// Fallback: use anonymous guest ID
const identity = await sdk.identity.get();
console.log("Guest ID:", identity.subject);
}
// 2. Process Payment
if (caps.pay.purchase) {
try {
const result = await sdk.pay.purchase({ productId: "100_coins" });
if (result.status === "CONFIRMED") {
console.log("Purchase Success! Ref:", result.transactionRef);
await sdk.ui.toast("100 Coins added!");
}
} catch (error) {
console.error("Payment error:", error);
}
}