Funstack SDK Demo

Wallet Connection

Disconnected

Wallet Address

Not connected
0 XP Tokens

Integration Code

Connect Wallet
// Connect wallet and initialize SDK
const accounts = await window.ethereum.request({
  method: 'eth_requestAccounts'
});

await sdk.initContracts(window.ethereum);
await sdk.auth.login({ walletAddress: accounts[0] });

Rewarded Ads

Watch an ad to earn XP tokens! Rewards are claimable on-chain.

Show Rewarded Ad
// Request and show a rewarded ad
const session = await sdk.ads.requestAd({
  placementId: 'main-reward'
});

const receipt = await sdk.ads.show(session.id);
console.log('Earned:', receipt.rewardAmount, 'XP');

Claim XP On-Chain

Claim your earned XP as real tokens on Immutable zkEVM.

0
Pending XP
0
Claimed Today
Claim XP with Ad
// Claim XP on-chain (requires watching ad)
const result = await sdk.claimXPWithAd(pendingXP, {
  placementId: 'xp_claim'
});

console.log('TX Hash:', result.txHash);
console.log('Explorer:', result.explorerUrl);

Game Events

Track progress and submit scores to the leaderboard.

Track Progress Event
// Track game progress events
await sdk.progress.trackEvent({
  type: 'LEVEL_COMPLETE',
  value: 1,
  metadata: {
    level: 5,
    score: 12500,
    timeTaken: 180
  }
});
Submit to Leaderboard
// Submit score to leaderboard
const result = await sdk.leaderboards.submit({
  boardId: 'high-scores',
  score: 9500
});

console.log('Rank:', result.rank);

SDK Setup

Add the SDK to your HTML5 game in minutes.

1. Include the SDK
<script src="/xp-sdk.browser.js"></script>
2. Initialize the SDK
// Initialize SDK when your game loads
const sdk = await window.XPSDK.init({
  gameId: 'your-game-id',
  env: 'production',  // or 'testnet'
  debug: true
});

// Listen for SDK events
sdk.on('auth:login', (player) => {
  console.log('Player:', player.id);
});

sdk.on('adComplete', (session, receipt) => {
  console.log('Reward:', receipt.rewardAmount);
});

Debug Log