Community Integration

Integrate Looping Binary's authentication and coin system into your community platform for premium memberships, rewards, and social features.

What You Get

  • Single sign-on for community members
  • Premium membership subscriptions with LB Coins
  • Reward active members with coins
  • Tip other users for helpful content
  • Unlock exclusive features with coins

Step 1: Premium Membership Subscription

Allow users to upgrade to premium membership using LB Coins:

JavaScript
// User upgrades to premium membership
const subscription = {
  type: 'PREMIUM',
  duration: 'MONTHLY',
  price: 30 // LB Coins per month
};

// Check user balance
const balanceResponse = await fetch('https://api.loopingbinary.com/api/wallets/me', {
  headers: { 'Authorization': 'Bearer ' + token }
});

const { balance } = await balanceResponse.json();

if (balance >= subscription.price) {
  // Transfer to Subscription Treasury
  const subscribeResponse = 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: 'SUBSCRIPTION',
      amount: subscription.price,
      reason: `Premium Membership - $${subscription.duration}`
    })
  });

  if (subscribeResponse.ok) {
    // Grant premium access
    await upgradeToPremium(user.id, subscription.duration);
    console.log(' Premium membership activated!');
  }
} else {
  console.log(' Insufficient balance');
}

Step 2: Tipping Feature

Allow users to tip each other for helpful posts or contributions:

JavaScript
// User tips another user for helpful content
const tip = {
  amount: 5, // LB Coins
  recipientUserId: 456,
  postId: 'post_789'
};

const tipResponse = await fetch('https://api.loopingbinary.com/api/coins/transfer', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer ' + token
  },
  body: JSON.stringify(({
    toUserId: tip.recipientUserId,
    amount: tip.amount,
    reason: `Tip for Post #$${tip.postId}`
  })
});

if (tipResponse.ok) {
  console.log(` Tipped $${tip.amount} coins!`);
  // Show success notification
  await notifyUser(tip.recipientUserId, 'You received a tip!');
} else {
  console.log(' Tip failed - Insufficient balance');
}

Step 3: Reward Active Members (Admin)

Reward community members for engagement and contributions:

JavaScript (Admin)
// Reward top contributors (admin operation)
const topContributors = [
  { userId: 10, contributions: 50, reward: 20 },
  { userId: 25, contributions: 35, reward: 15 },
  { userId: 42, contributions: 28, reward: 10 }
];

for (const contributor of topContributors) {
  const rewardResponse = 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: contributor.userId,
      amount: contributor.reward,
      reason: 'Monthly Top Contributor Reward'
    })
  });

  if (rewardResponse.ok) {
    console.log(` Rewarded User #$${contributor.userId} with $${contributor.reward} coins`);
  }
}

Community Best Practices

  • Set minimum tip amounts to prevent spam
  • Display user coin balances on profiles
  • Show tipping leaderboards to encourage engagement
  • Send notifications for tips and rewards
  • Implement daily/monthly tip limits if needed
  • Reward consistent contributors automatically