@iamgame/wallet-sdk-server
v0.1.3
Published
IAMGame Wallet backend SDK — secret-key server-to-server client: verify wallet sessions and run the high-frequency money ledger.
Maintainers
Readme
@iamgame/wallet-sdk-server
Backend SDK for IAMGame Wallet. Authenticated with your secret
key (sk_) — server-to-server only. Two jobs: verify wallet sessions at login, and run the
high-frequency money ledger. The browser must never hold an sk_ or call win on itself.
All amounts are bigint integer base units (lamports / micro-USDC).
import { IAMGameWalletServer } from "@iamgame/wallet-sdk-server";
const wallet = new IAMGameWalletServer({
secretKey: process.env.IAMGAME_WALLET_SECRET_KEY!, // sk_live_... / sk_test_...
baseUrl: "https://api-wallet.iamgame.com/v1",
});
// Login: verify the player's session token, then mint your own app JWT.
const verified = await wallet.verifySession(sessionToken);
// → { userId, walletAddress, wallets, identities, environment }
// Ledger: lock once, run the hot path, settle the net.
const s = await wallet.ledger.openSession({ userId, gameCode: "momentum", currency: "USDC", lockAmount: 50_000_000n });
await wallet.ledger.bet({ sessionToken: s.sessionToken, transactionUuid: "r1-bet", amount: 1_000_000n, round: "r1" });
await wallet.ledger.win({ sessionToken: s.sessionToken, transactionUuid: "r1-win", referenceTransactionUuid: "r1-bet", amount: 1_800_000n, round: "r1", roundClosed: true });
const { payout } = await wallet.ledger.settleSession(s.sessionToken);See the full guide at https://wallet.iamgame.com/docs.
