Quickstart
Time to first call: ~3 minCasino SDK reads casino content from the Betchain CMS over HTTP. Initialize it once with your API URL, then read game, jackpot and tournament data through the useCasino hook.
Show samples as
1
Install the package
Installation guideCasino, Content and Swarm ship in one package, so a single install covers every surface.
.sh
npm install @softconstruct/betchain-core-client
Registry access firstThe package comes from a private registry. Configure the @softconstruct scope and your BetChain license key before installing.
2
Initialize the CMS client
Web: call initCMSCasino once at app start. Flutter: a single initSDK brings up the casino CMS client (cmsCasinoCore) along with the socket session.
.ts
1import { initCMSCasino } from '@softconstruct/betchain-core-client/casino';2 3initCMSCasino({4 version: 2,5 partner: 18749451,6 platform: 'desktop',7 apiUrl: 'https://cms-api.your-host.com'8});Parameters
| Name | Type | Required | Description |
|---|---|---|---|
apiUrl | string | Yes | Base URL of your CMS API. |
partner | number | Yes | Your partner identifier in the CMS. |
version | 1 | 2 | Yes | CMS content version to read from. |
platform | 'desktop' | 'mobile' | Yes | Which platform content tree to serve. |
3
Read the game catalog
Pass the method reference to useCasino. The hook returns data, loading and error state, plus makeRequest for re-running with new params.
.ts
1import { getCasinoGames } from '@softconstruct/betchain-core-client/casino';2import { useCasino } from '@softconstruct/betchain-core-client/hooks';3 4const useCasinoGames = () => {5 const { data, isLoading, hasError, message } = useCasino(getCasinoGames, {6 params: { language: 'eng', limit: 20 },7 dependencies: []8 });9 10 return { data, isLoading, hasError, message };11};RefetchingValues in dependencies trigger a refetch when they change. Use makeRequest for user-driven pagination or filtering instead.
4
Handle errors
The useCasino hook exposes hasError and message. A direct call returns the raw CMS envelope instead — check message and errors, and treat a null data as a failure.
.ts
1import { useEffect } from 'react';2import { getCasinoGames } from '@softconstruct/betchain-core-client/casino';3import { useCasino } from '@softconstruct/betchain-core-client/hooks';4 5const useCasinoGames = () => {6 const { data, hasError, message, isLoading } = useCasino(getCasinoGames, {7 params: { language: 'eng', limit: 20 },8 dependencies: []9 });10 11 useEffect(() => {12 if (hasError) {13 console.error('Casino request failed:', message);14 }15 }, [hasError, message]);16 17 return { data, isLoading, hasError };18};What next
Was this page helpful?