Skip to content

TopTrenDev/somnia-plinko-smart-contract

Repository files navigation

🎰 Somnia Plinko Game — Smart Contract

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

🚀 Features

  • 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

📦 Tech Stack

  • Solidity 0.8.28
  • Hardhat
  • TypeScript
  • Ethers.js
  • Somnia Testnet

🔧 Hardhat Configuration (Somnia)

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

📜 Contract Overview

Main Contract: Plinko.sol

Core responsibilities:

  • Start game round
  • Request randomness
  • Calculate Plinko result (slot landing)
  • Payout winnings
  • Emit game events

Key Functions

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);

🧪 Running Tests

npm install
npx hardhat test

📤 Deployment

Deploy to Somnia Testnet:

npx hardhat run scripts/deploy.ts --network somniaTestnet

🤝 Contributions

PRs welcome! If you'd like to extend features (leaderboards, NFT skins, etc.), feel free to contribute.


📬 Contact

For help or questions, open an issue or reach out via GitHub Discussions.

Twitter Discord Telegram

About

Somnia plinko game smart contract: lightweight, provably fair on-chain Plinko game built for the Somnia blockchain, featuring VRF-powered randomness, configurable risk modes, and clean integration with Hardhat + Solidity.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors