T
TrueCash
/ Developers
Marketplace Sell Items Get Started
NEW TrueCash Game Developer SDK v1.0

Add Web3 Payments
to Your Game in 5 Lines

No blockchain knowledge required. No gas fees for your players. Just drop in our SDK and start accepting TRUECASH instantly — in any web game, Unity WebGL export, or React app.

Quick Start →
5
Lines of Code
$0
Gas for Players
<2s
Transaction Time

Quick Start

1

Add the SDK to your page

One script tag — that's all. Works with any HTML page, React, Vue, or Unity WebGL export.

HTML
<!-- Add before your closing </body> tag -->
<script src="https://market.truecash.io/sdk/truecash-sdk.js"></script>
2

Initialize and connect

Create one SDK instance. Call connect() when the player clicks your "Connect Wallet" button.

JavaScript
// Initialize once (e.g. in your game's main.js)
const tc = new TrueCash({ network: 'bsc' });

// Connect player's wallet (call on button click)
const address = await tc.connect();
console.log('Player connected:', address);
// → "Player connected: 0xABCD...1234"
3

Accept a payment

Call pay() when a player buys something. They sign a message in MetaMask — no BNB gas required.

JavaScript
// Player buys a Legendary Sword for 50 TRUECASH
const result = await tc.pay({
    to:     '0xYourGameWallet...',  // your revenue wallet
    amount: 50,                     // TRUECASH tokens
    item:   'Legendary Sword'        // shown in MetaMask
});

if (result.success) {
    unlockSword();  // your game logic here!
    console.log('TX:', result.explorerUrl);
}

Complete Example

A full shop screen — copy and paste this into any HTML file.

complete-shop.html
<!DOCTYPE html>
<html><body>

  <button id="connectBtn">Connect Wallet</button>
  <button id="buyBtn" disabled>Buy Sword (50 TRUECASH)</button>
  <p id="status"></p>

  <script src="https://market.truecash.io/sdk/truecash-sdk.js"></script>
  <script>
    const tc     = new TrueCash({ network: 'bsc' });
    const status = document.getElementById('status');

    document.getElementById('connectBtn').addEventListener('click', async () => {
      const addr = await tc.connect();
      status.textContent = `Connected: ${addr.slice(0,6)}...`;
      document.getElementById('buyBtn').disabled = false;
    });

    document.getElementById('buyBtn').addEventListener('click', async () => {
      status.textContent = 'Waiting for signature...';
      const result = await tc.pay({
        to:     '0xYourGameWallet...',
        amount: 50,
        item:   'Legendary Sword'
      });
      status.textContent = result.success
        ? `⚔️ Sword unlocked! TX: ${result.txHash.slice(0,10)}...`
        : 'Payment failed.';
    });
  </script>
</body></html>

API Reference

new TrueCash(config)

Creates a new SDK instance. Call once per page.

config.network 'bsc' | 'bsc_testnet' — Target network (default: 'bsc')
config.relayerUrl Optional — Override the Paymaster relayer endpoint
await tc.connect() → Promise<string>

Connects the player's MetaMask wallet. Automatically switches to BSC network. Returns the wallet address.

await tc.pay({ to, amount, item }) → Promise<Result>

Signs and submits a zero-gas TRUECASH payment via the Paymaster.

to string — Recipient wallet address (your game's revenue wallet)
amount number — Amount in TRUECASH tokens (not wei)
item string — Item name shown in the MetaMask signature prompt
Returns: { success: true, txHash: "0x...", orderId: "GAME-...", explorerUrl: "https://bscscan.com/tx/..." }
await tc.getBalance(address?) → Promise<number>

Returns the TRUECASH balance for any address. Defaults to the connected wallet.

tc.onPayment(callback)

Register a callback for successful payments. Chainable: tc.onPayment(fn).onError(fn2)

Platform Support

🌐

Web Games

Any HTML5/JavaScript game. Drop the script tag in, works instantly.

<script src="truecash-sdk.js">
🎮

Unity WebGL

Export your Unity game to WebGL and call the SDK via jslib plugins.

Application.ExternalCall("tc.pay...")
⚛️

React / Vue

Import and use in any modern frontend framework.

import TrueCash from 'truecash-sdk'

FAQ

Do my players need BNB to pay gas? +

No — that's the whole point. The TrueCash Paymaster covers 100% of gas fees on behalf of your players. They only need TRUECASH tokens in their wallet.

What does it cost me as a developer? +

The SDK is free. The Paymaster covers gas costs for your players. You receive 100% of every TRUECASH payment directly to your wallet.

How do players get TRUECASH? +

Players can buy TRUECASH in our presale at truecash.io, or on PancakeSwap after the DEX launch. You can link your players directly to the presale page.

Is there a minimum balance requirement? +

Players need at least 2,000 TRUECASH in their wallet to use zero-gas payments. This is an anti-spam measure. The SDK automatically checks this and shows a friendly error if the balance is too low.

Can I test on testnet first? +

Yes! Pass network: 'bsc_testnet' to the constructor and set your own testnet contract addresses in the config.