Created
March 30, 2025 09:49
-
-
Save coderwithsense/638e85552603ae81f2be499c8627cfe6 to your computer and use it in GitHub Desktop.
Deploys new PredictionGame contracts and tracks them by creator and token pair
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.20; | |
import "./PredictionGame.sol"; | |
contract PredictionFactory { | |
address[] public allGames; | |
mapping(address => address[]) public userGames; | |
event GameCreated(address game, address creator); | |
function createPredictionGame( | |
string memory pair, | |
uint256 targetPrice, | |
uint256 expiry, | |
uint256 creatorFee | |
) external { | |
PredictionGame game = new PredictionGame( | |
msg.sender, | |
pair, | |
targetPrice, | |
expiry, | |
creatorFee | |
); | |
allGames.push(address(game)); | |
userGames[msg.sender].push(address(game)); | |
emit GameCreated(address(game), msg.sender); | |
} | |
function getAllGames() external view returns (address[] memory) { | |
return allGames; | |
} | |
function getGamesByCreator(address user) external view returns (address[] memory) { | |
return userGames[user]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment