A decentralized cookie clicker game built on Aptos blockchain featuring on-chain clicks, aggregator-based tracking, private entry functions, and orderless transaction processing for optimal performance.
- Rapid Clicking: Click as fast as you want! Multiple click transactions can be submitted simultaneously
- No Race Conditions: Aptos aggregators handle concurrent modifications safely
- Parallel Processing: Clicks processed out-of-order without conflicts
- Better UX: No waiting for previous transaction confirmation
- Every click is a blockchain transaction using aggregators
- Concurrent-safe cookie counting with
aggregator_v2 - Private entry functions only (no public functions exposed)
- True decentralized gaming experience
- Click to Earn: Start with 1 cookie per click
- Upgrades: Buy multipliers (2x, 5x, 10x clicks)
- Auto-Clickers: Passive cookie generation (Grandma, Factory, Bank)
- Prestige System: Reset progress for permanent bonuses
- Language: Move on Aptos
- Key Feature: Aggregator-based orderless transactions
- Structure: Private entry functions only
- Testing: Comprehensive unit tests
- Wallet Integration: Petra, Martian, Pontem
- Real-time Updates: Event-driven UI updates
- Optimistic Updates: Immediate feedback
- Transaction Management: Queue system for parallel processing
cookie-clicker-aptos/
โโโ contracts/
โ โโโ sources/
โ โ โโโ cookie_clicker.move # Main smart contract
โ โโโ tests/
โ โ โโโ cookie_clicker_tests.move # Unit tests
โ โโโ Move.toml # Move configuration
โโโ frontend/
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โโโ hooks/ # Game state management
โ โ โโโ utils/ # Aptos integration
โ โ โโโ App.tsx # Main app
โ โโโ package.json
โ โโโ tsconfig.json
โโโ README.md
- Aptos CLI
- Node.js (v16+)
- Aptos Wallet (Petra, Martian, or Pontem)
-
Navigate to contracts directory:
cd contracts -
Initialize Aptos account (if you haven't):
aptos init --network testnet
-
Compile the contract:
aptos move compile
-
Run tests:
aptos move test -
Deploy to testnet:
aptos move publish --named-addresses cookie_clicker=default
-
Note the deployed address and update
MODULE_ADDRESSin/frontend/src/utils/aptosClient.ts
-
Navigate to frontend directory:
cd frontend -
Install dependencies:
npm install
-
Update contract address in
src/utils/aptosClient.ts:const MODULE_ADDRESS = "YOUR_DEPLOYED_CONTRACT_ADDRESS";
-
Start development server:
npm start
-
Open browser to
http://localhost:3000
- Connect Wallet: Click "Connect Wallet" and choose your Aptos wallet
- Initialize Player: Click "Start Cookie Adventure!" to create your on-chain profile
- Click Cookies: Click the big cookie to earn cookies (each click is a blockchain transaction!)
- Buy Upgrades: Increase your click multiplier with upgrades
- Purchase Auto-Clickers: Generate passive cookie income
- Prestige: Reset progress for permanent bonuses when you reach 1M cookies
- Wait for each transaction to confirm
- Race conditions with rapid clicking
- Sequential processing bottlenecks
- Poor user experience
- โ Submit multiple clicks instantly
- โ Aggregators prevent race conditions
- โ Parallel transaction processing
- โ Smooth, responsive gameplay
cd contracts
aptos move testcd frontend
npm test- Double Cursor: 100 cookies โ 2x multiplier
- Golden Touch: 1,000 cookies โ 5x multiplier
- Divine Finger: 10,000 cookies โ 10x multiplier
- Grandma: 50 cookies โ 1 cookie/sec
- Factory: 500 cookies โ 10 cookies/sec
- Bank: 5,000 cookies โ 100 cookies/sec
- Threshold: 1,000,000 cookies
- Reward: 1 prestige point per 1M cookies
- Benefit: +1x base click multiplier per prestige point
// Orderless click processing
entry fun click_cookie(account: &signer) {
let player_aggs = borrow_global_mut<PlayerAggregators>(addr);
let click_agg = borrow_global<ClickAggregator>(addr);
// Atomic, concurrent-safe operations
aggregator::add(&mut player_aggs.total_cookies, click_agg.click_multiplier);
aggregator::add(&mut player_aggs.lifetime_clicks, 1);
}// Multiple clicks submitted simultaneously
const handleRapidClick = async () => {
const clickPromises = Array(clickCount).fill(null).map(() =>
submitTransaction({
function: `${MODULE_ADDRESS}::cookie_clicker::click_cookie`,
arguments: []
})
);
// Process all clicks in parallel
Promise.allSettled(clickPromises);
};- Testnet Only: This implementation is configured for Aptos testnet
- Gas Fees: Each click requires a small amount of APT for gas
- Wallet Connection: Ensure your wallet is connected to Aptos testnet
- Contract Address: Update the MODULE_ADDRESS after deployment
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
- Mainnet deployment
- Additional upgrade tiers
- Leaderboard system
- NFT achievements
- Mobile optimization
- Sound effects and animations
Experience the future of blockchain gaming with orderless transactions on Aptos! ๐ชโก