Game Wallet
Each game on Games.fun has its own wallet that receives and manages player tokens. Your game wallet is the foundation for implementing token-based mechanics - players transfer tokens to it, and you convert them to points, items, or any in-game value.
The game wallet provides:
Secure token storage
Point conversion system
Withdrawal capabilities
Real-time balance tracking
Game Wallet Setup
First, create a wallet to receive player tokens:
// Using your API key
const response = await fetch('https://games.fun/api/games/wallet', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'your-games-fun-api-key'
}
});
const { wallet } = await response.json();
const gameWalletAddress = wallet.address;Store this wallet address - players will transfer tokens to it.
Token Transfers
Client Side
Players transfer tokens using the SDK:
Server Side
Your server validates and processes transfers:
Point System
You can implement any point conversion system. Here's a basic example:
Withdrawals
Let players withdraw their points back as tokens:
Error Handling
Handle common token scenarios:
Development Mode
Test token flows without real transfers:
Best Practices
Validation
Always verify token type
Validate amounts and recipients
Check for duplicate transfers
Use atomic transactions
State Management
Keep real-time balances
Handle disconnections
Sync client/server state
Log all transfers
User Experience
Show clear token/point values
Explain conversion rates
Provide transaction history
Handle errors gracefully
Next Steps
Game Server - Set up your game server
React Integration - Use with React components
Development Guide - Testing and deployment
Last updated