This script integrates the Clinch SDK into your web app, enabling secure communication between your parent window and the embedded iframe. Below is a brief overview of the callbacks and configuration.
Configuration Object (config)
The config object passed to loadClinch contains settings that control the behaviour of the Clinch web app.
constconfig={operatorId:'your_operator_id',gameId:"solitaire",clinchUrl:"http://embed-sandbox.clinch.gg",companyName:"your company name",language:"en",paymentType:"lightning",showSats:true,lightningAddress:"[email protected]",logging:true,};
operatorId: This ID will be provided to you by THNDR
gameId: 'solitaire' or 'blocks'
clinchUrl: This is the URL for the clinch iframe. This will be provided by THNDR for sandbox (embed-sandbox.clinch.gg) and production (embed.clinch.gg) environments.
companyName: This is your company name that will be shown by the users balance of their wallet on your platform.
language: Two-letter country code. If language is not supported, defaults to english.
paymentType: This must be 'lightning'.
showSats: The iframe shows balances in USD. If you want to show a satoshi balance as well, set this to true.
lightningAddress: The users lightning address that their winnings are sent to
logging: When set to true, this enables debug mode, allowing additional logging in the console for troubleshooting.
Callbacks
The SDK requires four key callback functions, each responsible for handling specific actions within the Clinch web app.
getToken: Retrieves the authentication token for the user.
getBalance: Returns the current balance for the user.
onPayInvoice: You will receive a bolt11 invoice, which you should pay from your users wallet balance.
Example Code Overview
The code integrates the Clinch SDK with the specified configuration and callbacks: