SDK
The Suigar SDK is the TypeScript package that helps integrators build valid Suigar v2 game transactions on Sui without manually assembling each Move call.
GitHub: Suigar SDK repository Playground: playground.suigar.com
What this is for
Use the SDK when your app needs to:
- build standard Suigar game transactions from normal application inputs
- read live game limits from chain instead of hardcoding them
- list or inspect open PvP coinflip lobbies
- decode Suigar event payloads into application-friendly values
- hand a built transaction to a wallet, backend signer, or transport layer
The SDK is not a full app framework. It does not manage wallet connection, signatures, or your UI state. Its job is to give you the correct Suigar-aware client surface on top of a Sui client.
Partner integrations
If you are a Suigar partner, this is the setup to follow.
Register the SDK with your partner wallet address before building any transaction:
import { SuiGrpcClient } from '@mysten/sui/grpc';
import { suigar } from '@suigar/sdk';
const client = new SuiGrpcClient({
baseUrl: 'https://fullnode.mainnet.sui.io:443',
network: 'mainnet',
}).$extend(
suigar({
partner: '0xpartner_wallet_address',
}),
);
Partner rule:
- always configure
partnerduring extension registration - always pass the partner wallet address
- never pass a slug, project name, or display label
- never try to inject partner attribution manually in each builder call
Why this is the recommended setup:
- partner attribution is injected automatically into supported onchain metadata
- the same partner configuration is reused for standard and PvP flows
- reserved metadata keys such as
partnerandreferrerare ignored when passed manually
What has shipped so far
The current SDK project already includes:
- network-aware config for
mainnetandtestnet - standard game builders for Coinflip, Limbo, Plinko, Range, and Wheel
- PvP Coinflip create, join, cancel, and unresolved-lobby lookup helpers
- typed onchain game parameter reads through
client.suigar.getGameParameters(game, options?) - public
@suigar/sdk/gamesexports for shared game option types - public
@suigar/sdk/utilsexports for parser helpers, numeric helpers, and shared constants - generated BCS event parsers for standard and PvP game flows
- automatic partner metadata injection when the extension is registered with a partner wallet
- SDK-managed caching for repeated onchain reads such as game parameter lookups
- bulk PvP Coinflip lobby lookups that skip per-object fetch or parse failures unless
throwOnError: trueis passed - a live integration example and playground flow you can test at playground.suigar.com
- support for Sui TypeScript SDK v2 only
What the SDK does
- Registers a Suigar extension on top of a Sui client.
- Resolves the right Suigar package ids for
mainnetandtestnet. - Resolves supported coin types and matching price info object ids.
- Builds ready-to-send
Transactionobjects for Suigar games. - Reads and caches live onchain game parameters such as min and max stake.
- Encodes optional metadata into the byte arrays expected by the contracts.
- Exposes BCS event structs for decoding game result events.
- Can serialize built transactions to base64 when a wallet or backend expects that format.
- Can register under a custom extension name instead of
client.suigar.
Typical usage flow
Most integrations follow the same sequence:
- Create a Sui client for
mainnetortestnet. - Register the SDK extension with
suigar(). - Read config or parameters if your UI needs live limits or supported coins.
- Build a transaction with
client.suigar.tx. - Sign and execute it, or serialize it for another signer.
- Decode returned events when you want structured result data.
If your app has a betting form, step 3 is usually part of the form load.
If your app receives already-validated bet requests from another system, you may
skip that read and move directly to building.
Public package exports
The package has three public entrypoints:
@suigar/sdkforsuigarandSuigarClient@suigar/sdk/gamesfor game option types such asBuildCoinflipTransactionOptions,BuildCreatePvPCoinflipTransactionOptions,BuildJoinPvPCoinflipTransactionOptions,BuildCancelPvPCoinflipTransactionOptions,CoinSide, andPvPCoinflipAction@suigar/sdk/utilsfor helpers and constants such asparseGameDetails,parseCoinType,fromMoveFloat,fromMoveI64,toBigInt,toU8,toU16,DEFAULT_GAS_BUDGET_MIST,DEFAULT_LIMBO_MULTIPLIER_SCALE,DEFAULT_RANGE_SCALE, andRANGE_POINT_LIMIT
Individual transaction builders are not exported from the package root. Use the registered client extension under client.suigar.tx.
Runtime requirements:
- Node.js
^22.18.0 || >=24 - ESM project configuration (
"type": "module") @mysten/suiv2@mysten/bcsv2
This SDK targets Sui TypeScript SDK 2.0+ only. Follow the official Sui 2.0 migration guide if your app still uses the pre-2.0 client API.
What you get at runtime
After registering the extension, the main runtime surface is:
client.suigar.getConfig()client.suigar.getGameParameters(game, options?)client.suigar.serializeTransactionToBase64(transaction, options?)client.suigar.getPvPCoinflipGames(options?)client.suigar.bcsclient.suigar.tx
Extension registration options:
partnerto inject partner attribution automatically into supported metadatacacheTtlto control the SDK onchain-read cache in millisecondsnameto register the extension under a different property such asclient.games
How to think about these options:
- use
partneronly when your integration should write partner attribution onchain - use
cacheTtlwhen your product repeatedly reads parameters and you want to trade freshness for fewer chain reads - use
nameonly whensuigarwould collide with another client extension or you want a different local naming convention
For one specific live PvP Coinflip object, use the generated object helper:
const game = await client.suigar.bcs.PvPCoinflipGame.get({
client,
objectId: '0xGAME_ID',
});
If you want to rename the extension:
const client = new SuiGrpcClient({
baseUrl: 'https://fullnode.mainnet.sui.io:443',
network: 'mainnet',
}).$extend(
suigar({
name: 'games',
}),
);
client.games.tx;
client.games.bcs;
Supported game flows
Standard bet builders:
PvP flow:
Integration flow
- Install the SDK and Sui peer dependencies.
- Create a Sui client on
mainnetortestnet. - If you are a partner, register the extension with
suigar({ partner: '0xpartner_wallet_address' })before building anything. - Build a game transaction with
client.suigar.tx. - Sign and execute the transaction, or serialize it to base64 for another signer.
Continue with the full integration guide.