{"id":49619956,"url":"https://github.com/suigar-gaming/sdk","last_synced_at":"2026-05-17T23:04:32.063Z","repository":{"id":352957130,"uuid":"1217254260","full_name":"Suigar-Gaming/sdk","owner":"Suigar-Gaming","description":"Suigar TypeScript SDK","archived":false,"fork":false,"pushed_at":"2026-05-17T21:51:43.000Z","size":1529,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-17T22:38:08.676Z","etag":null,"topics":["games","move","sdk","sui","sui-sdk","suigar","typescript","web3"],"latest_commit_sha":null,"homepage":"https://playground.suigar.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Suigar-Gaming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-21T17:45:33.000Z","updated_at":"2026-05-17T21:50:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Suigar-Gaming/sdk","commit_stats":null,"previous_names":["suigar-gaming/sdk"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/Suigar-Gaming/sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Suigar-Gaming%2Fsdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Suigar-Gaming%2Fsdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Suigar-Gaming%2Fsdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Suigar-Gaming%2Fsdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Suigar-Gaming","download_url":"https://codeload.github.com/Suigar-Gaming/sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Suigar-Gaming%2Fsdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33158772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"ssl_error","status_checked_at":"2026-05-17T22:39:10.741Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["games","move","sdk","sui","sui-sdk","suigar","typescript","web3"],"created_at":"2026-05-05T01:04:45.147Z","updated_at":"2026-05-17T23:04:32.050Z","avatar_url":"https://github.com/Suigar-Gaming.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Suigar Typescript SDK\n\nA collection of TypeScript SDKs for interacting with the Suigar contracts.\n\n## Docs Site\n\nFor complete Suigar SDK docs, visit [docs.suigar.com/sdk](https://docs.suigar.com/sdk).\n\nThis SDK builds on the Sui TypeScript SDK. For Sui client, transaction, and network APIs, visit the [Sui TypeScript SDK docs](https://sdk.mystenlabs.com/).\n\n## Suigar TypeScript SDK\n\nThe publishable package in this repository is [`@suigar/sdk`](packages/sdk). It provides utility classes, types, generated Move bindings, and transaction builders for applications that build Suigar v2 game transactions on Sui. The package is ESM-only and is built with `tsdown`.\n\nThe main integration path is the `suigar()` extension on top of a Sui client such as `SuiGrpcClient`. The SDK targets Sui TypeScript SDK 2.0+ and supports standard Suigar games plus PvP coinflip flows.\n\nRuntime requirements for `@suigar/sdk`:\n\n- Node.js `^22.18.0 || \u003e=24`\n- ESM project configuration (`\"type\": \"module\"`)\n\nPublic package entrypoints:\n\n- `@suigar/sdk` for `suigar()` and `SuigarClient`\n- `@suigar/sdk/games` for game option and action types\n- `@suigar/sdk/utils` for parser helpers, numeric helpers, and reusable constants\n\nUtility behavior from `@suigar/sdk/utils`:\n\n- `toBigInt(value)` accepts `bigint`, finite `number`, non-negative integer\n  `string`, and `boolean` inputs and returns a normalized non-negative `bigint`\n  while throwing `TypeError` for invalid input shapes and `RangeError` for\n  negative values\n- `toU8(value)` accepts a finite integer `number` or plain integer `string`\n  in the `0..255` range, throwing `TypeError` for non-numeric input and\n  `RangeError` for booleans, fractional values, or out-of-range integers\n- `toU16(value)` accepts a finite integer `number` or plain integer `string`\n  in the `0..65535` range, throwing `TypeError` for non-numeric input and\n  `RangeError` for booleans, fractional values, or out-of-range integers\n- `fromMoveI64(value)` converts a generated Move `i64` wrapper into a\n  JavaScript `number`\n- `fromMoveFloat(value)` converts a generated Move float struct into a\n  JavaScript `number`\n- `parseCoinType(type)` extracts the normalized first generic coin type from a\n  Move object type string and throws `TypeError` when no coin type can be parsed\n- `parseGameDetails(gameId, gameDetails)` decodes standard `BetResultEvent.game_details`\n  byte arrays into the expected string, number, and boolean values while\n  preserving the original on-chain keys\n\n## Building Locally\n\nTo get started, install [pnpm](https://pnpm.io/) and run commands from the repository root:\n\n```bash\n# Install all dependencies\npnpm install\n\n# Generate bindings and build the SDK package\npnpm --dir packages/sdk build\n\n# Build without regenerating contract bindings\npnpm --dir packages/sdk build:ci\n\n# Regenerate Move contract bindings only\npnpm --dir packages/sdk codegen\n```\n\nThe package implementation lives in `packages/sdk`. Build, codegen, test, and typecheck commands should be run with `pnpm --dir packages/sdk ...`.\n\n## Testing\n\nRun the SDK test suite:\n\n```bash\npnpm --dir packages/sdk test\n```\n\nRun TypeScript checking:\n\n```bash\npnpm --dir packages/sdk typecheck\n```\n\nRun a specific Vitest file:\n\n```bash\npnpm --dir packages/sdk exec vitest run test/unit/transactions.test.ts\n```\n\nRun a specific test name:\n\n```bash\npnpm --dir packages/sdk exec vitest run -t \"builds a coinflip transaction with the configured package id\"\n```\n\n## Playground\n\nThe repository includes a Next.js integration playground in [`apps/playground`](apps/playground). It demonstrates standard game transactions, PvP coinflip transactions, wallet integration, live transaction code previews, and event decoding.\n\nRun it locally:\n\n```bash\npnpm turbo run dev --filter='./apps/playground'\n```\n\nThen open [http://localhost:3000](http://localhost:3000).\n\n## Connecting to Sui Network\n\n`SuiGrpcClient` from `@mysten/sui/grpc` is the recommended client for Sui TypeScript SDK 2.0+ integrations.\n\nCommon gRPC fullnode URLs:\n\n- Testnet: `https://fullnode.testnet.sui.io:443`\n- Mainnet: `https://fullnode.mainnet.sui.io:443`\n\n```ts\nimport { SuiGrpcClient } from '@mysten/sui/grpc';\nimport { suigar } from '@suigar/sdk';\n\nconst client = new SuiGrpcClient({\n\tnetwork: 'testnet',\n\tbaseUrl: 'https://fullnode.testnet.sui.io:443',\n}).$extend(suigar());\n\nconst coins = await client.core.getCoins({\n\towner: '0xcc2bd176a478baea9a0de7a24cd927661cc6e860d5bacecb9a138ef20dbab231',\n});\n```\n\n## Getting Coins From The Faucet\n\nYou can request SUI from the testnet faucet at [faucet.sui.io](https://faucet.sui.io/).\n\n```ts\nimport { getFaucetHost, requestSuiFromFaucetV2 } from '@mysten/sui/faucet';\n\nawait requestSuiFromFaucetV2({\n\thost: getFaucetHost('testnet'),\n\trecipient:\n\t\t'0xcc2bd176a478baea9a0de7a24cd927661cc6e860d5bacecb9a138ef20dbab231',\n});\n```\n\n## Writing Suigar Transactions\n\nStandard Suigar games use `client.suigar.tx.createBetTransaction(gameId, options)` for `coinflip`, `limbo`, `plinko`, `range`, and `wheel`.\n\nThe SDK throws `RangeError` when the connected network, selected standard game,\nPvP action, or configured coin type is unsupported for the active config.\n\n```ts\nimport { SuiGrpcClient } from '@mysten/sui/grpc';\nimport { suigar } from '@suigar/sdk';\n\nconst client = new SuiGrpcClient({\n\tnetwork: 'testnet',\n\tbaseUrl: 'https://fullnode.testnet.sui.io:443',\n}).$extend(suigar());\n\nconst tx = client.suigar.tx.createBetTransaction('coinflip', {\n\towner: '0x123',\n\tcoinType: '0x2::sui::SUI',\n\tstake: 1_000_000_000n,\n\tside: 'heads',\n});\n\nconst base64 = await client.suigar.serializeTransactionToBase64(tx);\nconsole.log({ base64 });\n```\n\nConfigure partner attribution once during extension setup. `partner` must be the partner wallet address.\n\n```ts\nconst client = new SuiGrpcClient({\n\tnetwork: 'testnet',\n\tbaseUrl: 'https://fullnode.testnet.sui.io:443',\n}).$extend(suigar({ partner: '0xpartner_wallet_address' }));\n```\n\nConfigure SDK-managed on-chain read caching with `cacheTtl`, in milliseconds.\nThe default is 30 minutes. This cache is used by on-chain reads such as\n`getGameParameters`.\n\n```ts\nconst client = new SuiGrpcClient({ network, baseUrl }).$extend(\n\tsuigar({ cacheTtl: 30 * 60 * 1000 }),\n);\n```\n\nRead typed on-chain game parameters with `getGameParameters(game, options?)`.\nUse this when an app needs current game bounds such as min/max stake or\ngame-specific configuration limits. The SDK first reads the selected game's\nsettings object from SweetHouse, then reads that game's coin-specific\n`Parameters\u003cT\u003e` object, parses it with the generated game type, and caches the\nparsed result.\n\nWhen a returned parameter field is a generated Move float struct, such as\n`min_target_multiplier`, `max_target_multiplier`, `min_rtp`, or `max_rtp`, use\n`fromMoveFloat()` before treating it as a normal JavaScript number.\n\n```ts\nconst parameters = await client.suigar.getGameParameters('coinflip', {\n\tcoinType: '0x2::sui::SUI',\n});\n\nconsole.log(parameters.min_stake);\n```\n\nPass `ignoreCache: true` to refresh the on-chain read and replace the cached\nvalue.\n\n## Standard Game APIs\n\nUse `createBetTransaction(gameId, options)` for standard games:\n\n- `coinflip`: `side: 'heads' | 'tails'`\n- `limbo`: `targetMultiplier: number`, `scale?: number`\n- `plinko`: `configId: number`\n- `range`: `leftPoint: number`, `rightPoint: number`, `outOfRange?: boolean`, `scale?: number`\n- `wheel`: `configId: number`\n\nShared options include `owner`, `coinType`, `stake`, optional `cashStake`, optional `betCount`, optional `metadata`, optional `gasBudget`, and optional `allowGasCoinShortcut`.\n\n`stake` is the logical wager passed into the Move call. Use `cashStake` only when the withdrawn balance should differ from the logical stake. Pass plain application values to `metadata`; the SDK encodes metadata into on-chain byte arrays.\n\n```ts\nconst limboTx = client.suigar.tx.createBetTransaction('limbo', {\n\towner: '0x123',\n\tcoinType: '0x2::sui::SUI',\n\tstake: 1_000_000_000n,\n\ttargetMultiplier: 2.5,\n});\n\nconst rangeTx = client.suigar.tx.createBetTransaction('range', {\n\towner: '0x123',\n\tcoinType: '0x2::sui::SUI',\n\tstake: 1_000_000_000n,\n\tleftPoint: 25,\n\trightPoint: 75,\n\toutOfRange: false,\n});\n```\n\n## PvP Coinflip APIs\n\nPvP coinflip uses `client.suigar.tx.createPvPCoinflipTransaction(action, options)` for `create`, `join`, and `cancel`.\n\nCreate a public PvP coinflip lobby:\n\n```ts\nconst tx = client.suigar.tx.createPvPCoinflipTransaction('create', {\n\towner: '0x123',\n\tcoinType: '0x2::sui::SUI',\n\tstake: 1_000_000_000n,\n\tside: 'heads',\n\tisPrivate: false,\n});\n```\n\nJoin a PvP coinflip lobby:\n\n```ts\nconst tx = client.suigar.tx.createPvPCoinflipTransaction('join', {\n\towner: '0x123',\n\tcoinType: '0x2::sui::SUI',\n\tgameId: '0xGAME_ID',\n});\n```\n\nCancel a PvP coinflip lobby:\n\n```ts\nconst tx = client.suigar.tx.createPvPCoinflipTransaction('cancel', {\n\towner: '0x123',\n\tcoinType: '0x2::sui::SUI',\n\tgameId: '0xGAME_ID',\n});\n```\n\nList unresolved PvP coinflip lobbies:\n\n```ts\nconst games = await client.suigar.getPvPCoinflipGames({ limit: 20 });\n\nfor (const game of games) {\n\tconsole.log(game.id);\n\tconsole.log(game.coin_type);\n}\n```\n\nFetch one live PvP coinflip game object with the generated BCS helper:\n\n```ts\nconst game = await client.suigar.bcs.PvPCoinflipGame.get({\n\tclient,\n\tobjectId: '0xGAME_ID',\n});\n```\n\n## Reading Events\n\nGenerated event decoders are available under `client.suigar.bcs`. Parser helpers such as `parseGameEvent`, `parseGameDetails`, `fromMoveFloat`, `fromMoveI64`, and `parseCoinType` are exported from `@suigar/sdk/utils`.\n\n```ts\nimport {\n\tfromMoveFloat,\n\tparseGameDetails,\n\tparseGameEvent,\n} from '@suigar/sdk/utils';\n\nconst { gameId, eventName } = parseGameEvent(event)!;\nconst decoded = client.suigar.bcs.BetResultEvent.parse(event.bcs);\nconst parsedDetails = parseGameDetails(gameId, decoded.game_details);\nconst price = fromMoveFloat(decoded.adjusted_oracle_usd_coin_price);\n```\n\n## Useful Package Docs\n\n- [`packages/sdk/README.md`](packages/sdk/README.md) contains the complete package API guide.\n- [`apps/playground/README.md`](apps/playground/README.md) documents the integration playground.\n- [`AGENTS.md`](AGENTS.md) documents repository conventions for AI-assisted development.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuigar-gaming%2Fsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuigar-gaming%2Fsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuigar-gaming%2Fsdk/lists"}