Skip to main content

Gameplay

Initialize

The Game Client MUST initialize Kalamba SDK, so the wrapper can be correctly set up.

import { KalambaSdk } from '@kalamba/sdk'
const sdk = new KalambaSdk({ messagePort: window.parent })

You can optionally provide custom codecs for fully typed openGame() and play() calls.

Configure wrapper

The Game Client MUST configure Kalamba SDK Wrapper. This step also performs a compatibility check between the SDK version and the wrapper version.

await sdk.configure({
gameName: 'MY GAME',
gameVersion: '1.2.1',
})
caution

sdk.configure() is asynchronous and must be awaited before calling sdk.openGame(). The wrapper verifies SDK compatibility during this step. If the SDK version is incompatible, the wrapper will either redirect to a compatible version or display an error.

Open Game

The Game Client MUST open the game before playing.

const openGameResponse = await sdk.openGame()

It will connect to RGS and fetch configuration. After "Open Game", sdk.config is available to use.

Play

const playResponse = await sdk.play(contractPlayPayload)

It will make play request and can be done multiple times.

It is possible to send extra parameters if needed:

const playResponse = await sdk.play(contractPlayPayload, extraPlayPayload)

in some cases game client may want to communicate with RGS without making a bet, then it can be done by setting bet in contract payload to null:

const playResponse = await sdk.play({ bet: null }, extraPlayPayload)