@playmos/sdk 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @playmos/sdk
|
|
2
|
+
|
|
3
|
+
Stablecoin payments for games on Base. One SDK for in-app purchases (1%), skill-game prize-pool entries (10%, 60/30/10), and agent economies. USD in, USDC on-chain — no crypto UX for your players.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @playmos/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quickstart — the no-wallet sandbox
|
|
12
|
+
|
|
13
|
+
The public sandbox key `pk_test_playmos_sandbox` runs against a real Playmos test service on Base Sepolia. **You don't need a wallet:** on a `pk_test` key with no `wallet` configured, the SDK routes to a server-settle path where Playmos signs and submits the on-chain transaction for you. You still get a real, confirmed `txHash` — just signed by the service. No wallet, no gas, no crypto.
|
|
14
|
+
|
|
15
|
+
The key comes wired to two demo games: `game_sandbox_iap` (IAP) and `game_sandbox_skill` (prize pool).
|
|
16
|
+
|
|
17
|
+
### In-app purchase — `pay()`
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { Playmos } from "@playmos/sdk";
|
|
21
|
+
|
|
22
|
+
// No wallet in the sandbox — Playmos signs the test payment for you.
|
|
23
|
+
const playmos = new Playmos({ apiKey: "pk_test_playmos_sandbox" });
|
|
24
|
+
|
|
25
|
+
const payment = await playmos.pay({
|
|
26
|
+
gameId: "game_sandbox_iap", // the public sandbox IAP game
|
|
27
|
+
amount: "4.99", // USD, as a string
|
|
28
|
+
sku: "gems_500", // your product id
|
|
29
|
+
playerId: "player_abc", // your user id
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
payment.status; // "confirmed" — real, on Base Sepolia
|
|
33
|
+
payment.txHash; // 0x… open on sepolia.basescan.org
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Skill-game entry — `enterRound()`
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const entry = await playmos.enterRound({
|
|
40
|
+
gameId: "game_sandbox_skill",
|
|
41
|
+
roundId: "5m-5944009",
|
|
42
|
+
amount: "1.00", // grows this round's pool
|
|
43
|
+
playerId: "player_abc",
|
|
44
|
+
});
|
|
45
|
+
// entry.status === "confirmed"; entry.split is the on-chain 60/30/10 breakdown
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Verify before you grant
|
|
49
|
+
|
|
50
|
+
Grant items on a verified confirmation — never on the client `pay()` return alone.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const result = await playmos.verify(payment.id); // on-chain read
|
|
54
|
+
if (result.status === "confirmed") grantItem(result.playerId, result.sku);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Mock mode — offline, deterministic
|
|
58
|
+
|
|
59
|
+
For CI and wiring checks, `mock: true` returns instant, deterministic results with **no network and no chain**. Results carry `mock: true` and use the real status union, so your handling code sees the exact production shape.
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const playmos = new Playmos({ apiKey: "pk_test_playmos_sandbox", mock: true });
|
|
63
|
+
const payment = await playmos.pay({
|
|
64
|
+
gameId: "game_sandbox_iap", sku: "gems_100", amount: "4.99", playerId: "player_abc",
|
|
65
|
+
});
|
|
66
|
+
// instant — payment.status === "confirmed", payment.mock === true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Mock mode is not test mode: mock is fabricated and offline; the sandbox is real and settles on Base Sepolia.
|
|
70
|
+
|
|
71
|
+
## Production — real player wallets
|
|
72
|
+
|
|
73
|
+
Outside the sandbox (a `pk_live` key), or whenever you want the player to sign their own on-chain transaction, configure a wallet connector. With a wallet present the SDK uses the client-signed path instead of server-settle.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const playmos = new Playmos({
|
|
77
|
+
apiKey: "pk_live_…",
|
|
78
|
+
wallet: { connector: "base-account" }, // or "injected" in a wallet browser
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Promote by swapping the key — the same code that passed in the sandbox works live.
|
|
83
|
+
|
|
84
|
+
## Docs
|
|
85
|
+
|
|
86
|
+
Full documentation — skill games, webhooks, gas, payouts, agent economies, and the REST API — at [playmos.io](https://playmos.io).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playmos/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Playmos SDK — stablecoin payments for games on Base. One SDK for IAP (1%), skill-game prize-pool entries (10%, 60/30/10), and agent economies. USD in, USDC on-chain, no crypto UX for players.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|