Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Contract for Minigame: Single-Button Platformer #57

Closed
jimenezz22 opened this issue Jan 22, 2025 · 11 comments · Fixed by #85
Closed

Smart Contract for Minigame: Single-Button Platformer #57

jimenezz22 opened this issue Jan 22, 2025 · 11 comments · Fixed by #85
Assignees
Labels
Dojo Maintainer: Daniel Maintainer: Rolo Medium MiniGame ODBoost This issue will be available ONLY during the ODBoost

Comments

@jimenezz22
Copy link
Contributor

jimenezz22 commented Jan 22, 2025

Description

This task involves implementing a smart contract function, submitScore, using Dojo Engine and Cairo, to record scores achieved in a minigame. The function will also handle logic for granting rewards or additional points based on the player's performance.

A good reference for this implementation is the frontend issue Minigame: Single-Button Platformer (GitHub link), which outlines how the minigame operates and tracks player performance. Aligning the smart contract logic with this frontend issue will ensure consistency across the system.


Tasks

Define the submitScore Function 🏗️

  • Create a Cairo function submitScore that takes the following parameters:
    • player_id: The ID of the player submitting the score.
    • tamagotchi_id: The ID of the Tamagotchi linked to the game.
    • score: The score achieved in the minigame.
  • Validate the inputs to ensure:
    • The player_id and tamagotchi_id exist and are correctly linked.
    • The score is non-negative and within a reasonable range.
  • Store the score in the appropriate on-chain data structure, such as a mapping or table.

Implement Reward Logic 🎁

  • Add logic to grant rewards based on the submitted score:
    • Define thresholds for rewards (e.g., score >= 100 grants bonus points or items).
    • Update the Tamagotchi's attributes (e.g., happiness, health, or experience).
  • Ensure rewards align with the frontend game logic, avoiding discrepancies between the user experience and on-chain outcomes.

Integrate with Dojo Engine ⚙️

  • Leverage Dojo Engine components to manage entity systems for players and Tamagotchis.
  • Ensure compatibility with existing entities and systems in the BabyBeasts ecosystem.

Testing and Validation ✅

  • Write unit tests in Cairo to validate:
    • Proper score recording.
    • Correct reward assignment based on various score thresholds.
  • Test integration with the frontend to confirm consistency with the game flow.

Deliverables 📂

  • Fully implemented submitScore function in Cairo.
  • Reward logic that updates Tamagotchis' attributes based on scores.
  • Test suite ensuring the reliability of score recording and reward assignment.
  • Documentation detailing the function parameters, logic, and examples of usage.

Acceptance Criteria 🎯

  • The submitScore function records scores accurately on-chain.
  • Rewards are assigned correctly and reflect in the player's Tamagotchi attributes.
  • The smart contract logic aligns seamlessly with the frontend issue Minigame: Single-Button Platformer.
  • All tests pass, and the integration is smooth and bug-free.

Additional Notes 📝

  • Follow best practices in Cairo for security and gas optimization.
  • Coordinate with the frontend team to ensure proper alignment of game logic and on-chain interactions.
@jimenezz22 jimenezz22 added Dojo Maintainer: Daniel Medium ODBoost This issue will be available ONLY during the ODBoost labels Jan 22, 2025
@ryzen-xp
Copy link

Hi,
I am proficient Blockchain developer expert in Dojo Cairo , Rust and Solidity and also in web development.

please /assign this issue .
Thank You !!

@SoarinSkySagar
Copy link

may i start working on this @jimenezz22 ?

background: cairo dev with 5 months of experience and regular contributor at @keep-starknet-strange

eta: 2 days

@ShantelPeters
Copy link

I'd be happy to do this.

@aniruddhaaps
Copy link

Hey, I'm new to this platform and want to contribute to this issue.
To be able to solve this issue, I will implement the submitScore function in Cairo by validating player and Tamagotchi IDs, recording scores on-chain, and giving rewards in terms of predefined thresholds. Rewards will include updates to the Tamagotchi's attributes such as happiness or experience. Sufficient unit testing will ensure accuracy and alignment with the frontend logic for seamless integration.

@Supa-mega
Copy link

Could I try solving this?

@1nonlypiece
Copy link

Application for Contribution

I am excited about the opportunity to contribute to this issue and am confident that my expertise aligns well with the requirements. With a strong background in Cairo programming and decentralized application development on StarkNet, I bring a well-rounded skill set to deliver an effective solution.

Relevant Expertise

  • Blockchain & Smart Contracts: Extensive experience with StarkNet, Stellar, and Rust, specializing in developing secure and optimized smart contracts, blockchain integrations, and high-performance backend infrastructure.
  • Backend Development: Well-versed in API design, server-side logic, and scalable system architecture, ensuring efficient and seamless backend performance.
  • Frontend Engineering: Skilled in crafting interactive and responsive UI components using React and Next.js, enhancing the user experience for blockchain-based platforms.

Why Consider My Application?

My proven track record of delivering high-quality, optimized solutions in blockchain and full-stack development sets me apart. I have a deep understanding of smart contract security, decentralized architectures, and the synergy between frontend, backend, and blockchain layers—ensuring a seamless and efficient implementation.

ETA

I expect to have a working solution ready within 48 hours. Please let me know if I can proceed with the implementation.

@Jagadeeshftw
Copy link

Proposal to Work on the Issue

I am eager to contribute to this issue and believe I am well-suited for the task, given my extensive experience in Cairo programming and building decentralized applications on StarkNet. My expertise spans across multiple domains crucial for this implementation:

  • Smart Contracts & Blockchain Development: Proven expertise in StarkNet, Stellar, and Rust, with hands-on experience in developing secure and efficient smart contracts, blockchain integrations, and high-performance backend systems.
  • Backend Engineering: Strong background in designing and managing scalable APIs, handling server-side operations, and ensuring robust backend performance for blockchain applications.
  • Frontend Development: Proficient in building intuitive and responsive frontend interfaces using React and Next.js, ensuring seamless interaction between users and blockchain-based applications.

Why Assign This to Me?

I have a track record of delivering high-quality solutions efficiently, with a deep understanding of smart contract security, decentralized architectures, and full-stack development. My ability to bridge frontend, backend, and blockchain components ensures a well-rounded, optimized solution.

Estimated Timeline

I anticipate delivering a fully functional solution within 2 days. Please let me know if I can proceed.

I am excited about the opportunity to contribute and look forward to collaborating!

Best regards,
Jagadeesh B

@Villarley
Copy link

Hi 🚀,

I’m Santiago Villarreal Arley, a developer with a strong background in front-end and back-end Web3 development. As a proud Diamond Contributor and member of Dojo Coding, I’ve worked on impactful projects like StarkNet and Stellar, winning the Buildathon Web3 Hackathon for my work on BuildMyEvent.

For the Single-Button Platformer Minigame Smart Contract, I can:

Implement submitScore: Validate inputs, store scores on-chain, and ensure data integrity.
Design Reward Logic: Define thresholds (e.g., scores ≥100), update Tamagotchi attributes, and align rewards with the frontend.
Integrate with Dojo Engine: Manage player and Tamagotchi entities, ensuring ecosystem compatibility.
Testing & Optimization: Write unit tests, conduct integration testing, and optimize for gas efficiency.
I’d love to contribute to this exciting project and ensure a seamless and rewarding player experience. Looking forward to collaborating! 😊

@pablomadrigal
Copy link

I'm Pablo Madrigal.

I'm a Fullstack Developer with more than 5 years of experience primarily on React and Node.js and now learning web3, I'm also part of Dojo Coding ⛩️ and have experience working in Cairo in the last Winter Hackathon, one example of the Cairo Contracts created are in the Github of Devote

Problem

Smart Contract for Minigame: Single-Button Platformer

Solution

  1. Create a map node to save the information of the different users and Tamagotchi
  2. Create the function to ensure that player_id and tamagotchi_id exist in the blockchain in the correct Cairo contract
  3. Create the function submitScore that saves the score of the player with that Tamagotchi
  4. Define thresholds for rewards
  5. Update the Tamagotchi status in the corresponding Cairo Smart Contract
  6. Integrate with Dojo Engine
  7. Create unit test for the contract
  8. Create the documentation of the functions created

ETA 3-4 days

@jimenezz22
Copy link
Contributor Author

@Villarley any updates?

@Villarley
Copy link

working on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dojo Maintainer: Daniel Maintainer: Rolo Medium MiniGame ODBoost This issue will be available ONLY during the ODBoost
Projects
None yet
Development

Successfully merging a pull request may close this issue.