A fun, blockchain-integrated Fruit Ninja-style game built using React (JSX) and powered by the Solana blockchain. Players slash fruits to earn tokens based on their score. Tokens are distributed from a house wallet through a backend server using a secure claim system.
- Frontend: React (JSX)
- Backend: Node.js (Express via
server.js) - Blockchain: Solana
- Token: Custom SPL Token
- ๐ Fruit Ninja-style gameplay
- ๐ JWT-secured score submission & token claim
- ๐ฐ Token rewards based on score tiers
- ๐ธ Airdrops from a House Wallet
- ๐ Solana Devnet integration
git clone https://github.com/Anantdadhich/fruityslice.gitnpm installCreate a .env file in the root of your project and fill in:
PAYER_WALLET=your_base58_encoded_secret_key
JWT_SECRET=your_jwt_secret
JWT_EXPIRY=1h
AUTH_TOKEN=static_auth_token_if_applicable
VITE_BACKEND=http://localhost:3001Run your wallet/token setup script to generate:
- โ House Wallet Address
- โ Token Mint Address
- โ House Token Account
Save those and update the frontend/backend with:
const TOKEN_MINT = new PublicKey("your_token_mint");
const PAYER = Keypair.fromSecretKey(bs58.decode(process.env.PAYER_WALLET));
const HOUSE_WALLET = PAYER.publicKey;- The frontend renders the Fruit Ninja game
- Player score is tracked
- On game over, players can claim rewards
handleClaim()sends the score to the backend, which validates it, calculates rewards, and triggers a token transfer
Handles:
- โ JWT authentication
- โ
POST /api/loginโ returns JWT token - โ
POST /api/transfer-tokensโ transfers SPL tokens to playerโs wallet based on score
Uses:
@solana/web3.jsto interact with Devnet- JWT for session security
- In-memory
specialrewardClaimedfor limited bonus rewards
export const getSliceReward = (score) => {
if (score < 10) return 0;
if (score < 20) return 0.005 * LAMPORTS_PER_SOL;
if (score < 50) return 0.01 * LAMPORTS_PER_SOL;
if (score < 100) return 0.03 * LAMPORTS_PER_SOL;
return 0.05 * LAMPORTS_PER_SOL;
};- Everything runs on Solana Devnet, no real SOL involved.
- Make sure to fund your house wallet with devnet SOL using:
solana airdrop 2 <house_wallet_address> --url devnetMade by Anant โ Full Stack Developer experimenting with blockchain gaming on Solana.
Feel free to reach out or contribute!