Add Secret Vaults Game Leveraging Pyth Entropy V2 #75
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Pyth Examples Contribution
Type of Contribution
Project Information
Secret Vaults
Pyth Product Used:
Blockchain/Platform:
Directory Structure
Description
Built for the hackathon. May contain bugs. Use at your own risk.
Overview:
Secret Vaults is a cryptographic guessing game leveraging Pyth Entropy V2 for verifiable on-chain randomness. Players create secret vaults containing hidden words known only to the contract, while others attempt to guess them for rewards. If the reveal deadline passes without a correct guess, the vault creator can reclaim the locked funds, including their initial deposit and any accumulated guess fees. Each vault’s secret word is composed of a random adjective and noun pair, generated securely using Pyth Entropy V2. The project demonstrates fair randomness, on-chain verifiability, and transparent game logic.
Technologies:
Pyth Entropy Solidity SDK
^2.1.0Solidity
^0.8.28Deployment:
Network: Base Sepolia (can be deployed on any network supporting Pyth Entropy V2)
Entropy contract:
0x41c9e39574f40ad34c79f1c99b66a45efb830d4cGame contract:
0x2cDD7E1c2069C8B9b9d62242410CB87F78764705Frontend implementations can vary creatively. An example demo is available here:
Live Demo: https://secret-vaults.vercel.app/
Implementation Details
The
SecretVaultcontract integrates Pyth Entropy V2 as a randomness oracle to generate secret answers derived from a predefined adjective–noun wordlist.Workflow:
A player invokes
requestVaultGeneration(), providingMIN_DEPOSITplus the on-chain entropy fee fromgetFeeV2(). This callsentropy.requestV2()and records aVaultRequestkeyed by the resulting sequence number. When Pyth Entropy later triggers theentropyCallback(), the contract deterministically derives a secret from the providedrandomNumberusing_generateFromEntropy(), commits the hashkeccak256(answer, randomness, sequenceNumber)to create the vault, and initializes its prize pool with the user’s deposit.Key functions include:
requestVaultGeneration()– requests new random vault generationsubmitGuess()– allows players to guess and potentially claim the prize poolrevealVault()– enables vault creators to reclaim funds after expirationView utilities –
getVault(),getVaultCount(),getEntropyFee()Commitment-based design ensures secrets remain hidden until reveal. The system prevents replay and collision through
usedCommitments, ties each random value to a specific request via sequence numbers, and uses explicit fee validation and structured errors to maintain consistent game economics and state transitions.Future Extensions:
Potential enhancements include ERC-20 token support as underlying asset, expanded wordlists, numeric secrets, and progressive clue systems to increase difficulty and engagement.