Skip to content

Conversation

@kiv1n
Copy link

@kiv1n kiv1n commented Oct 25, 2025

Pyth Examples Contribution

Type of Contribution

  • New Example Project (Adding a new example to demonstrate Pyth integration)
  • Bug Fix (Fixing an issue in existing examples)
  • Documentation Update (Improving README, comments, or guides)
  • Enhancement (Improving existing functionality or adding features)
  • Hackathon Submission (Submitting a project from a hackathon)

Project Information

Project/Example Name: Shark Battles - Prediction Battle Platform

Pyth Product Used:

  • Pyth Price Feeds
  • Pyth Entropy
  • Multiple Products
  • Other: ____

Blockchain/Platform:

  • Ethereum/EVM
  • Solana
  • Aptos
  • Sui
  • Fuel
  • Starknet
  • TON
  • Other: ____

Description

What does this contribution do?

This contribution adds a comprehensive prediction battle platform that demonstrates advanced integration of both Pyth Network price feeds and Pyth Entropy for verifiable randomness. Shark Battles is a gamified prediction platform where users compete to predict cryptocurrency price movements within specific time periods, featuring a dual reward system that combines skill-based and luck-based incentives.

How does it integrate with Pyth?

The project showcases dual Pyth integration:

Pyth Price Feeds Integration:

  • Real-time price data retrieval for multiple cryptocurrency assets
  • Battle start/end price recording for accurate change calculations
  • Price change percentage calculations in basis points
  • Support for any Pyth-supported price feed ID

Pyth Entropy Integration:

  • Verifiable randomness for fair random reward distribution
  • Entropy callback implementation for transparent winner selection
  • Provably fair random number generation for luck-based rewards

What problem does it solve or demonstrate?

This example demonstrates how to build engaging DeFi applications that combine:

  • Real-time Oracle Data: Using Pyth price feeds for accurate, low-latency price information
  • Verifiable Randomness: Implementing fair random reward systems using Pyth Entropy
  • Social Gaming: Integration with Farcaster IDs for social platform compatibility
  • Dual Reward Mechanics: Balancing skill-based predictions with luck-based incentives
  • L2 Optimization: Gas-efficient implementation suitable for Layer 2 networks

Directory Structure (for new examples)

entropy/sharkbattles/
├── contracts/
│   └── Battlefield.sol           # Main prediction battle contract with Pyth integrations
├── ignition/
│   └── modules/
│       └── Battlefield.ts        # Deployment configuration for Base Sepolia
├── scripts/
│   ├── create-predictionts.ts    # Utility for creating test predictions
│   ├── process-started-battle.ts # Battle start processing with price feeds
│   ├── process-ended-battle.ts   # Battle end processing with entropy
│   └── data/                     # Battle configurations and test data
├── test/
│   └── Battlefield.ts            # Comprehensive contract tests
├── artifacts/                    # Compiled contract artifacts
├── package.json                  # Dependencies including Pyth SDKs
├── hardhat.config.ts            # Network configuration
└── README.md                    # Comprehensive documentation

Testing & Verification

How to Test This Contribution

The project includes comprehensive testing setup and deployment scripts for easy verification.

Prerequisites

  • Node.js version: 18+
  • Other dependencies: Hardhat
  • Access to Base Sepolia testnet
  • Web3 wallet with Base Sepolia ETH for testing

Setup & Run Instructions

# Navigate to the project directory
cd entropy/sharkbattles

# Install dependencies
npm install

# Run comprehensive tests
npx hardhat test

# Deploy to Base Sepolia testnet
npx hardhat ignition deploy ignition/modules/Battlefield.ts --network baseSepolia

# Create test predictions
npx hardhat run scripts/create-predictionts.ts --network baseSepolia

# Process battle lifecycle
npx hardhat run scripts/process-started-battle.ts --network baseSepolia
npx hardhat run scripts/process-ended-battle.ts --network baseSepolia

Deployment Information (if applicable)

Network: N/A

Contract Address(es): N/A

Demo URL: N/A

Checklist

Code Quality

  • Code follows existing patterns in the repository
  • Proper error handling implemented
  • No hardcoded values (use environment variables where appropriate)

Testing

  • Tested locally and works as expected
  • All existing functionality still works (no breaking changes)

Additional Context

Related Issues

N/A

Screenshots/Demo (if applicable)

N/A

Notes for Reviewers

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant