Minting Coins Guide
Learn how to properly mint LB Coins for users. This guide covers best practices, security considerations, and common use cases.
What is Minting?
Minting is the process of creating new LB Coins and adding them to a user's wallet. Only administrators with proper API keys can mint coins. This operation is irreversible and should be used with caution.
When to Mint Coins
Welcome Bonuses
Reward new users with coins when they sign up or complete onboarding.
Achievement Rewards
Mint coins when users complete milestones, challenges, or achievements.
Referral Bonuses
Reward users for referring new members to your platform.
Promotional Campaigns
Distribute coins during special events, contests, or marketing campaigns.
Refunds
Mint coins to compensate users for cancelled services or purchases.
Basic Minting Example
Here's how to mint coins for a single user:
JavaScript
// Mint coins for a user
const mintCoinsForUser = async (userId, amount, reason) => {
const response = await fetch('https://api.loopingbinary.com/api/admin/mint', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.LB_API_KEY,
'Authorization': 'Bearer ' + adminToken
},
body: JSON.stringify(({
userId,
amount,
reason
})
});
if (response.ok) {
const result = await response.json();
console.log(`✓ Minted $${amount} coins for user #$${userId}`);
return result;
} else {
const error = await response.json();
console.error('✗ Minting failed:', error.message);
throw new Error(error.message);
}
};
// Example usage
await mintCoinsForUser(123, 50, 'Welcome bonus');Bulk Minting
Mint coins for multiple users at once:
JavaScript
// Bulk mint coins for multiple users
const bulkMintCoins = async (users) => {
const results = [];
for (const user of users) {
try {
const result = await mintCoinsForUser(
user.userId,
user.amount,
user.reason
);
results.push(({ success: true, userId: user.userId, result }));
} catch (error) {
results.push(({ success: false, userId: user.userId, error: error.message }));
}
}
return results;
};
// Example usage
const usersToReward = [
{ userId: 123, amount: 50, reason: 'Welcome bonus' },
{ userId: 456, amount: 100, reason: 'Referral reward' },
{ userId: 789, amount: 25, reason: 'Achievement unlocked' }
];
const results = await bulkMintCoins(usersToReward);
console.log(`Minted coins for $${results.filter(r => r.success).length} users`);Security Warnings
- Never expose your admin API key in client-side code
- Always validate user eligibility before minting
- Implement rate limiting to prevent abuse
- Log all minting operations for audit trails
- Set maximum mint limits per user/transaction
- Require multi-factor authentication for large mints
Best Practices
- Always include descriptive reasons for minting
- Keep minting amounts reasonable and consistent
- Test minting in development before production
- Monitor total coin supply regularly
- Document all minting policies clearly
- Review and approve large mint requests manually