@iamgame/wallet-sdk 0.1.0
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 +98 -0
- package/dist/index.cjs +2000 -0
- package/dist/index.d.cts +470 -0
- package/dist/index.d.ts +470 -0
- package/dist/index.js +1973 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @iamgame/wallet-sdk
|
|
2
|
+
|
|
3
|
+
Embedded wallet SDK for games on Solana. Telegram & browser-wallet auth, live balances, server-side signing, and key export — in one React provider.
|
|
4
|
+
|
|
5
|
+
- **Telegram Mini App login** — players inside Telegram are signed in with zero taps.
|
|
6
|
+
- **Browser wallet auth (SIWS)** — Phantom, Solflare, Backpack, auto-detected.
|
|
7
|
+
- **Server-side signing** — sub-200ms, no device-signing on the hot path.
|
|
8
|
+
- **Full wallet lifecycle** — provisioning, balances, withdrawals, key export.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @iamgame/wallet-sdk
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`react` and `react-dom` (>=18) are peer dependencies.
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
Wrap your app in the provider with your publishable key:
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { IAMGameWalletProvider } from "@iamgame/wallet-sdk";
|
|
24
|
+
|
|
25
|
+
export function App() {
|
|
26
|
+
return (
|
|
27
|
+
<IAMGameWalletProvider publishableKey="pk_live_...">
|
|
28
|
+
<Game />
|
|
29
|
+
</IAMGameWalletProvider>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Drop in the login component:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { WalletLogin } from "@iamgame/wallet-sdk";
|
|
38
|
+
|
|
39
|
+
<WalletLogin autoTelegram onSignIn={(user) => console.log("signed in", user.id)} />;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Use the hooks anywhere inside the provider:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { useWalletAuth, useWallet, useWalletBalance, useWalletSign } from "@iamgame/wallet-sdk";
|
|
46
|
+
|
|
47
|
+
function Wallet() {
|
|
48
|
+
const { status, user, logout } = useWalletAuth();
|
|
49
|
+
const wallet = useWallet();
|
|
50
|
+
const balance = useWalletBalance(wallet?.id);
|
|
51
|
+
|
|
52
|
+
if (status !== "authenticated") return <WalletLogin />;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div>
|
|
56
|
+
<div>{wallet?.address}</div>
|
|
57
|
+
<div>{balance?.tokens.map((t) => `${t.amount} ${t.symbol ?? t.mint}`).join(", ")}</div>
|
|
58
|
+
<button onClick={logout}>Log out</button>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Sign a transaction server-side (the wallet's key never touches the device):
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
const { signAction } = useWalletSign();
|
|
68
|
+
|
|
69
|
+
const { signedTxBase64, signature } = await signAction({
|
|
70
|
+
walletId: wallet.id,
|
|
71
|
+
txBase64, // base64 of a serialized (v0 or legacy) Solana transaction
|
|
72
|
+
label: "buy-ticket", // optional, recorded in the audit log
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Exports
|
|
77
|
+
|
|
78
|
+
| Kind | Names |
|
|
79
|
+
|------|-------|
|
|
80
|
+
| Client | `IAMGameWalletClient`, `IAMGameWalletProvider`, `WalletSdkError` |
|
|
81
|
+
| Hooks | `useWalletAuth`, `useWallet`, `useWalletBalance`, `useWalletSign`, `useWalletExport`, `useWalletTransferIn` |
|
|
82
|
+
| Components | `WalletLogin`, `WalletLoginModal`, `WalletAddress`, `WalletBalance`, `WalletWithdraw`, `WalletExport` |
|
|
83
|
+
| Adapters | `phantomAdapter`, `solflareAdapter`, `backpackAdapter`, `listSupportedWallets` |
|
|
84
|
+
| Session | `localStorageSession`, `inMemorySession` |
|
|
85
|
+
|
|
86
|
+
All components accept a `theme` prop so the UI matches your game.
|
|
87
|
+
|
|
88
|
+
## Get API keys
|
|
89
|
+
|
|
90
|
+
Sign up at [wallet.iamgame.com](https://wallet.iamgame.com) to create an app and get your publishable (`pk_`) and secret (`sk_`) keys. Sandbox (devnet) keys are issued instantly; live keys are enabled on approval.
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
Full guides and API reference: [wallet.iamgame.com/docs](https://wallet.iamgame.com/docs)
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|