A decentralized twist of the classic Hangman word game built on Base, featuring onchain rewards gasless transactions and playable as a MiniApp!
- Onchain Gameplay: Play the classic word-guessing game with blockchain integration
- Gasless Transactions: Powered by Coinbase Developer Platform's Paymaster service
- Availabe as a MiniApp: Play this in the Base Wallet or on Farcaster!
- Multiple Categories: Choose from various word categories to play
- Onchain Rewards: Win and claim rewards directly on the blockchain
- Smart Contract Integration: Built with Solidity and deployed on Base network
- Modern UI: Built with Next.js 14 and MiniKit
- Server Wallet: Server wallet handles reward management and disbursements
- Connect your wallet (supports Base network)
- Pay a small entry fee (currently 0.0001 ETH)
- Select a word category
- Play the game with 3 attempts per word
- Win and get your victory recorded onchain
- Claim your rewards at any time
-
Frontend:
- Next.js 14 (App Router)
- TypeScript
- TailwindCSS
- OnchainKit / MiniKit
- Wagmi v2
- Viem v2
-
Blockchain:
- Node.js 18+
- A Base compatible wallet (Coinbase Wallet, MetaMask, etc.)
- At least .0001 ETH on Base Sepolia
- Clone the repository:
git clone [repository-url]
cd hangman-onchain
- Install dependencies:
npm install
- Create a
.env.local
file with the following variables:
CDP_API_KEY_ID=your_cdp_api_key_id
CDP_API_KEY_SECRET=your_cdp_api_key_secret
CDP_WALLET_SECRET=your_cdp_wallet_secret
CDP_SIGNER_ADDRESS=your_cdp_signer_address
GAME_CONTRACT_ADDRESS_SEPOLIA=your_game_contract_address
- Start the development server:
npm run dev
The game uses a smart contract deployed on Base network that handles:
- Game entry fees
- Reward distribution
- Win recording
- Owner controls for fee management
- Base Sepolia: 0x352d55dd643ec049191d133a146be3086e0e1b85
startGame(bool payWithETH)
: Start a new gamerecordReward(address player, bool isETH)
: Record a player's winsetEntryFee(bool isETH, uint256 newFee)
: Update entry fees (owner only)setEthPayoutAmount(uint256 newAmount)
: Update ETH rewards (owner only)setUsdcPayoutAmount(uint256 newAmount)
: Update USDC rewards (owner only)
- The smart contract is verified on Base network
- Deploy using Foundry or Remix
- Update the contract address in your environment variables
- Change the owner address to your server wallet address to use
onlyOwner
functions
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
When a user wins, their address is recorded onchain via the /api/win
endpoint using a Coinbase CDP account. See RrcordOnchainSteps.md
for details. You must set the following in your .env.local
:
- CDP_API_KEY_ID
- CDP_API_KEY_SECRET
- CDP_WALLET_SECRET
- CDP_SIGNER_ADDRESS
- GAME_CONTRACT_ADDRESS_SEPOLIA