API
This page covers only the v0.1 capabilities and semantics defined in the public release spec (docs/spec-0.1_publish.md).
Initialize
import { PHSDK } from "@playsout/hybrid-sdk";
const sdk = await PHSDK.init({
pay: { productMapping },
});productMapping
The product config defines token / amount / chain / payee; the client only passes productId.
See: Examples
Pay
sdk.pay.purchase({ productId })
Start an ERC20 transfer purchase.
const result = await sdk.pay.purchase({ productId: "coin_pack_1" });Returns:
{
status: "SUBMITTED" | "CONFIRMED" | "FAILED" | "REJECTED";
txHash?: string;
productId: string;
}sdk.pay.getEntitlements()
Query local entitlements (Phase 1: Local Entitlements).
const { entitlements } = await sdk.pay.getEntitlements();Example response (shape):
{
"entitlements": [
{ "id": "remove_ads", "type": "non_consumable", "active": true },
{ "id": "coin_pack_1", "type": "consumable", "balance": 2000 }
]
}Wallet
sdk.wallet.getAccounts()
Get account list (address identity).
const accounts = await sdk.wallet.getAccounts();sdk.wallet.getChainId()
Get the current chain.
const chainId = await sdk.wallet.getChainId();sdk.wallet.switchChain(chainId)
Request a chain switch (if supported by the wallet).
await sdk.wallet.switchChain(8453);Env
sdk.env.getCapabilities()
Used to check host support for modules/methods at runtime (recommended before critical flows).
const caps = await sdk.env.getCapabilities();UI (optional)
UI capabilities are host-defined; SDK only exposes optional hooks and fallback behavior.
await sdk.ui.toast?.("Payment submitted");Events
sdk.on(eventName, handler)
Listen to wallet account/chain changes:
sdk.on("wallet.accountsChanged", ({ accounts }) => console.log(accounts));
sdk.on("wallet.chainChanged", ({ chainId }) => console.log(chainId));If your SDK build exposes
sdk.off, use it to remove listeners; refer to SDK typings for details.