A badge and leaderboard automation system for Arena community tokens and NFTs. This system automatically tracks token holders and NFT owners, assigns badges based on configurable criteria, and generates dynamic leaderboards.
- Badge Scheduler: Automatically collects NFT and token holder data and sends to Arena API endpoints
- Leaderboard Scheduler: Generates HTML leaderboards for token holders
- Multiple Project Support: Configure and run multiple projects with different tokens and NFTs
- API Key Rotation: Supports multiple Moralis API keys with automatic rotation when rate limits are reached
- Error Handling: Dynamic rescheduling based on error types for resilient operation
- Wallet Mapping: Optional feature to combine NFT holders based on Twitter handles
- Clone the repository
- Run
npm install - Create a
.envfile with the following variables:
MORALIS_API_KEYS=["your-moralis-api-key", "your-backup-moralis-api-key"]
ALCHEMY_API_KEY=your-alchemy-api-key
BADGE_KEYS={"projectName":"your-api-key"}
Project-specific configurations are stored in the config/projects/ directory. Each project has its own configuration file (e.g., boi.json) with the following structure:
{
"scheduler": {
"badgeIntervalHours": 6,
"badgeRetryIntervalHours": 2, //optional
"leaderboardIntervalHours": 3, //optional
"leaderboardRetryIntervalHours": 2 //optional
},
"walletMappingFile": "wallets.json", //optional
"enableLeaderboard": true //optional
}Badge configurations are stored in config/badges/ directory, with files named after the project (e.g., boi.json).
Leaderboard configurations are stored in config/leaderboards/ directory.
Run the badge scheduler to automatically fetch token and NFT holder data and send it to the Arena API:
npm run *projectname*:badgesFor verbose logging:
npm run *projectname*:badges:verboseRun the leaderboard scheduler to automatically generate HTML leaderboards for token holders:
npm run *projectname*:leaderboardFor verbose logging:
npm run *projectname*:leaderboard:verboseTo run both the badge and leaderboard schedulers simultaneously:
npm run *projectname*:runFor verbose logging:
npm run *projectname*:run:verboseAll generated files are saved to the output/ directory. Logs are stored in the logs/ directory.
The system supports mapping multiple wallets to a single user via Twitter handles. This allows for aggregating token balances across multiple wallets. Enable this feature by setting sumOfBalances: true in the badge configuration.
Specific Twitter handles can be excluded from leaderboards by adding them to the excludedAccounts array in the badge configuration.
Certain accounts can be configured to always receive badges regardless of token/NFT holdings by adding them to the permanentAccounts array in the badge configuration.
The system automatically detects API rate limits and retry failures, rescheduling runs for a shorter interval (default: 2 hours) instead of the standard interval to recover more quickly from temporary issues.
npm testFor running badge or leaderboard generation once without scheduling:
npm run *projectname*:badge:once
npm run *projectname*:leaderboard:oncenpm run *projectname*:badge:dry-runnpm run *projectname*:badge:address