A fully on-chain Plinko game deployed on the Somnia blockchain, built using Solidity, Hardhat, and Chainlink VRF / Somnia RNG (depending on integration). This repository contains:
- Smart contract for Plinko game logic
- Deployment scripts (Hardhat)
- Test suite
- Example frontend integration guide
- Provably Fair Randomness using Somnia-compatible VRF / RNG
- Multiple risk modes
- Configurable reward multipliers
- Owner/admin controls for adjusting game parameters
- Lightweight and gas-efficient
- Upgradeable-ready structure
- Solidity 0.8.28
- Hardhat
- TypeScript
- Ethers.js
- Somnia Testnet
Your hardhat.config.ts should contain:
somniaTestnet: {
url: process.env.SOMNIA_RPC_URL,
chainId: 50311,
accounts: [process.env.SOMNIA_PRIVATE_KEY],
},Environment variables example:
SOMNIA_RPC_URL=https://rpc.testnet.somnia.network
SOMNIA_PRIVATE_KEY=0xyourkey
Core responsibilities:
- Start game round
- Request randomness
- Calculate Plinko result (slot landing)
- Payout winnings
- Emit game events
function play(uint8 risk) external payable returns (uint256 requestId);
function fulfillRandomness(uint256 requestId, uint256 random) internal;
function calculateReward(uint8 risk, uint256 slot) public view returns (uint256);npm install
npx hardhat test
Deploy to Somnia Testnet:
npx hardhat run scripts/deploy.ts --network somniaTestnet
PRs welcome! If you'd like to extend features (leaderboards, NFT skins, etc.), feel free to contribute.
For help or questions, open an issue or reach out via GitHub Discussions.