Telegram Community: here
PrediFi is a decentralized prediction protocol built on StarkNet. In a trustless, transparent, and secure environment, it allows users to predict future outcomes across various fields, including sports, finance, and global events. By utilizing starknet technology, PrediFi ensures that all predictions and their results are verifiable onchain and immutable, thus eliminating the need for intermediaries.
PrediFi is a groundbreaking decentralized platform designed to empower individuals, influencers, and communities to enter the dynamic world of prediction markets. Leveraging the transformative power of blockchain technology, PrediFi allows anyone to establish custom prediction markets focused on any event imaginable. This innovative approach provides a lively, engaging, and rewarding way to foster interaction within your community while monetizing the buzz and excitement surrounding trending topics.
In our fast-paced digital age, conversations about predictions are captivating; they span a wide range of subjects, from sports matchups and political elections to the latest pop culture phenomena. Imagine if you could transform those engaging discussions into tangible rewards! With PrediFi, you have the opportunity to create markets where individuals can wager on the outcomes of these events, turning their insights and forecasts into real-world returns.
PrediFi makes it easy to create prediction pools for a wide range of cultural and local events. You can set up pools for major sports championships and awards shows, but that's just the beginning. It's also perfect for engaging with the latest viral trends, community events, environmental happenings, and anything else that sparks buzz in your area. Whether it’s predicting the outcome of a local music festival or the next viral sensation.
The PrediFi protocol is modular and organized for clarity, security, and extensibility. Below is an overview of the main contract files and their purposes:
src/predifi.cairo
: Main contract logic, including pool management, staking, validation, and dispute resolution.src/interfaces/IERC20.cairo
: ERC20 token interface for STRK and other tokens.src/interfaces/ipredifi.cairo
: Main protocol interface, including pool management, dispute, and validator traits.src/interfaces/iUtils.cairo
: Utility interface (e.g., for price feeds).src/base/types.cairo
: Enums and structs for pools, statuses, categories, odds, stakes, and validators.src/base/events.cairo
: All protocol events (e.g., BetPlaced, UserStaked, PoolResolved).src/base/errors.cairo
: Centralized error messages and codes for all protocol operations.
All public and external functions, types, and events are documented using Cairo NatSpec comments for auditability and developer clarity.
Example:
/// @notice Places a bet on a pool.
/// @dev Transfers tokens from user, updates odds, and emits BetPlaced event.
/// @param pool_id The pool ID.
/// @param option The option to bet on.
/// @param amount The amount to bet.
fn vote(ref self: ContractState, pool_id: u256, option: felt252, amount: u256) { ... }
Guidelines:
- Use
@notice
for a summary of the function/type/event. - Use
@dev
for developer/auditor notes. - Use
@param
and@return
for all parameters and return values. - All new public/external functions must include NatSpec comments.
Requirements:
- Rust
- Cairo
- Starknet foundry
- Node
- Pnpm
Step 1:
-
Fork the repo
-
Clone the forked repo to your local machine
git clone https://github.com/your-user-name/auto-swap
- Setup contract:
cd contracts
// Install asdf scarb and starknet foundry:
curl --proto '=https' --tlsv1.2 -sSf https://sh.starkup.dev | sh
// Method 2:
Install asdf and install scarb, and starknet foundry: https://foundry-rs.github.io/starknet-foundry/getting-started/installation.html
- Add development tools
asdf set --home scarb 2.9.2
asdf set --home starknet-foundry 0.36.0
- Ensure installed properly
snforge --version
scarb --version
- Build
scarb build
- Test
snforge test
We provide a Docker DevContainer to simplify development and avoid local dependency issues.
- Docker installed and running
- Visual Studio Code with the Dev Containers extension
- Open the project in VS Code.
- Press CTRL + SHIFT + P → select “Dev Containers: Reopen in Container”.
- The container will build and install all required tools automatically.
Inside the container, run:
scarb build
scarb test
scarb fmt
scarb fmt --check
- If During running
scarb build
throw errorkilled
, Then increase your docker ram allocation and cores. and restart !
We welcome contributions! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/your-feature-name
) - Commit your changes with meaningful messages (
git commit -m 'feat: add new capability'
) - Test your changes thoroughly before submission
Before submitting your PR:
- Set up your environment variable:
export RPC_URL=https://api.cartridge.gg/x/starknet/mainnet
- All tests must pass locally before proceeding
- Ensure your branch is up to date with main (
git pull origin main
) - Include comprehensive test cases covering your changes
- Update documentation to reflect your modifications
- Provide a detailed description in your PR explaining:
- The problem solved
- Implementation approach
- Any potential impacts
- Request review from project maintainers
- Follow the existing code style and conventions
- Write clean, readable, and maintainable code
- Include comments for complex logic
- Keep commits focused and atomic
- All new public/external functions must include NatSpec comments
Need help with your contribution? You can:
- Open an issue in the GitHub repository
- Join our Telegram channel for community assistance
- Check existing documentation and discussions
We aim to review all contributions promptly and appreciate your efforts to improve the project!
- All critical logic is documented with NatSpec.
- Please report vulnerabilities responsibly.
For more details, see the inline NatSpec documentation in each contract file.