Tournaments Integration
Integrate Looping Binary's coin system into your gaming platform for tournament entry fees, prize pools, and automated payouts.
What You Get
- Collect entry fees in LB Coins
- Manage prize pools from Reward Treasury
- Automated winner payouts
- Tournament rankings and leaderboards
- Entry fee validation
Step 1: Tournament Entry
Collect entry fees when players register for tournaments:
JavaScript
// Player registers for tournament
const tournament = {
id: 'tournament_123',
name: 'Call of Duty Championship',
entryFee: 20, // LB Coins
prizePool: 500 // LB Coins
};
// Check player balance
const balanceResponse = await fetch('https://api.loopingbinary.com/api/wallets/me', {
headers: { 'Authorization': 'Bearer ' + token }
});
const { balance } = await balanceResponse.json();
if (balance >= tournament.entryFee) {
// Charge entry fee to General Treasury
const entryResponse = await fetch('https://api.loopingbinary.com/api/coins/transfer-to-treasury', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
},
body: JSON.stringify(({
treasuryType: 'GENERAL',
amount: tournament.entryFee,
reason: `Entry Fee: $${tournament.name}`
})
});
if (entryResponse.ok) {
await registerPlayerForTournament(user.id, tournament.id);
console.log('✓ Registered for tournament!');
}
} else {
console.log('✗ Insufficient balance');
}Step 2: Distribute Prizes (Admin)
After tournament ends, distribute prizes from Reward Treasury to winners:
JavaScript (Admin)
// Distribute prizes to winners (admin operation)
const winners = [
{ userId: 1, place: 1, prize: 250 },
{ userId: 2, place: 2, prize: 150 },
{ userId: 3, place: 3, prize: 100 }
];
for (const winner of winners) {
const payoutResponse = await fetch('https://api.loopingbinary.com/api/admin/treasury/transfer', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': adminApiKey,
'Authorization': 'Bearer ' + adminToken
},
body: JSON.stringify(({
fromTreasury: 'REWARD',
toUserId: winner.userId,
amount: winner.prize,
reason: `$${tournament.name} - Place #$${winner.place} Prize`
})
});
if (payoutResponse.ok) {
console.log(`✓ Paid $${winner.prize} coins to Place #$${winner.place}`);
}
}
console.log('✓ All prizes distributed!');Tournament Best Practices
- Verify entry fees before allowing tournament registration
- Display prize pool prominently on tournament page
- Store all transaction IDs for audit purposes
- Automate prize distribution after tournament ends
- Send notifications to winners when prizes are paid
- Keep detailed logs of all payouts