Quick Start
npm install @mythicalb/sdk
import { createMythicalSDK } from "@mythicalb/sdk";
const mythical = createMythicalSDK({
supabase: { url, anonKey },
game: {
id: "card_game",
modeId: "casual",
seasonId: "card_game_casual_season_1"
},
ardor: { hostOrigin: "https://store.mythicalbeings.io" },
polygon: { provider: window.ethereum }
});
API Modules
Who Needs What
Choose the right account level before building. Guest is fine for demos; email is required for anything permanent.
| Action | Guest | Email account | + Ardor wallet | + Polygon wallet |
|---|---|---|---|---|
| Play local / demo | ✅ | ✅ | ✅ | ✅ |
| Join multiplayer session | ✅ | ✅ | ✅ | ✅ |
| Save progress permanently | ❌ | ✅ | ✅ | ✅ |
| Appear in leaderboard | ❌ | ✅ | ✅ | ✅ |
| Claim Ardor reward | ❌ | ❌ | ✅ | — |
| Claim Polygon reward | ❌ | ❌ | — | ✅ |
| Transfer Ardor assets in-game | ❌ | ❌ | ✅ | — |
| Sign Polygon transaction | ❌ | ❌ | — | ✅ |
SDK Modules
| Module | Purpose |
|---|---|
auth |
Guest auth, magic links, current user, sign-out. |
profile |
Global Play Hub profile creation and updates. |
sessions |
Create, join, start, ready, finish, leave, and subscribe. |
wallets |
Link, unlink, and inspect Ardor or Polygon wallets. |
leaderboards |
Read seasons, standings, and recent results. |
rewards |
Check whether a player can claim rewards. |
ardor |
Use the existing embedded Ardor wallet bridge. |
polygon |
Use an EIP-1193 provider for signatures and transactions. |
Sessions
await mythical.auth.signInAsGuest("Guest Player");
await mythical.profile.getOrCreate();
const session = await mythical.sessions.create();
await mythical.sessions.setReady(session.session_id, true);
mythical.sessions.subscribe(session.session_id, {
onSessionChange: console.log,
onParticipantsChange: console.log
});
Profiles & Wallets
Supabase profiles are the account. Ardor and Polygon addresses are verified linked wallets.
await mythical.wallets.connect("polygon");
await mythical.wallets.connect("ardor");
const wallets = await mythical.wallets.getLinked();
Leaderboards & Rewards
Guest profiles can play but cannot submit permanent results or claim rewards through the SDK.
const eligibility = await mythical.rewards.canClaim({ chain: "polygon" });
if (eligibility.canClaim) {
const claim = await mythical.rewards.claim({
chain: "polygon",
rewardId: "season_1_top_10"
});
}
Register a Game
Create an idempotent migration for a new external game, mode, and active season.
npm run playhub:new-game -- \
--game-id=potion_lab \
--game-name="Potion Lab" \
--mode-id=casual \
--min-players=2 \
--max-players=2
Deploy Checklist
supabase db push --dry-run
supabase db push
supabase functions deploy playhub-wallet-challenge --project-ref zbmkhvpokopvhnochcjr
supabase functions deploy playhub-link-wallet --project-ref zbmkhvpokopvhnochcjr
supabase functions deploy playhub-unlink-wallet --project-ref zbmkhvpokopvhnochcjr
supabase functions deploy playhub-claim-reward --project-ref zbmkhvpokopvhnochcjr
npm run supabase:types
Ardor & Polygon
await mythical.ardor.connect({
appName: "My Game",
permissions: ["READ_ACCOUNT", "SIGN_TOKEN"]
});
const polygonAddress = await mythical.polygon.connect();
Examples
examples/playhub-minimal: guest, profile, create/join session.examples/playhub-react: React hook for auth/profile/session state.examples/playhub-wallets: link Ardor and Polygon wallets.examples/marketplace-demo: Ardor marketplace module.