{"id":18899900,"url":"https://github.com/carlosalegreur/constellation-chainlinkhackathon-2023","last_synced_at":"2026-03-02T04:30:17.915Z","repository":{"id":206401336,"uuid":"716543560","full_name":"CarlosAlegreUr/Constellation-ChainlinkHackathon-2023","owner":"CarlosAlegreUr","description":"Team project for Constellation, November's 2023 Chainlink Hackathon. Bet and fight against other people's imagination with your own unique NFTs in a fair way!","archived":false,"fork":false,"pushed_at":"2023-12-10T16:15:04.000Z","size":17257,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-31T09:19:04.661Z","etag":null,"topics":["automation","ccip","chainlink","functions","smart-contracts","solidity","vrf","web3"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CarlosAlegreUr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-09T11:04:28.000Z","updated_at":"2023-12-23T11:34:47.000Z","dependencies_parsed_at":"2024-11-08T08:48:07.452Z","dependency_job_id":"e582ea3a-5dbe-49c6-9381-93053012dfef","html_url":"https://github.com/CarlosAlegreUr/Constellation-ChainlinkHackathon-2023","commit_stats":null,"previous_names":["carlosalegreur/constellationchainlinkhackathon2023","carlosalegreur/constellation-chainlinkhackathon-2023"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarlosAlegreUr%2FConstellation-ChainlinkHackathon-2023","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarlosAlegreUr%2FConstellation-ChainlinkHackathon-2023/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarlosAlegreUr%2FConstellation-ChainlinkHackathon-2023/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarlosAlegreUr%2FConstellation-ChainlinkHackathon-2023/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CarlosAlegreUr","download_url":"https://codeload.github.com/CarlosAlegreUr/Constellation-ChainlinkHackathon-2023/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239879307,"owners_count":19712176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","ccip","chainlink","functions","smart-contracts","solidity","vrf","web3"],"created_at":"2024-11-08T08:47:48.509Z","updated_at":"2026-03-02T04:30:17.877Z","avatar_url":"https://github.com/CarlosAlegreUr.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PROMPT FIGHTERS❗❗❗🤯\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./repo-images/game-images/logoImage.jpg\" width=\"250\" alt=\"PromptFightersLogo\"\u003e\n\u003c/p\u003e\n\nDo you remember when you were a kid and you were using your toys to **_`create legendary fights`_**?\n\nHave you ever thought on **`betting and earning real money on`** fair **_`imagination battles`_** with your friends?\n\n**`Are you too busy`** to play with your imagination like when you were a kid but **`you wish you had the time`** for it?\n\nWell say no more, we present... **_`PROMPT FIGHTERS`_** ❗\n\n---\n\n### `VIDEO PRESENTATION` 📹\n\nClick on the image to watch the video on **`Youtube`**.\n\n\u003ca href=\"https://www.youtube.com/watch?v=NpHMpbXRhPA\" target=\"_blank\"\u003e\u003cimg src=\"https://img.youtube.com/vi/NpHMpbXRhPA/maxresdefault.jpg\" width=\"400\"\u003e\u003c/a\u003e\n\n---\n\n## Quick view on technlogies code for judges 🧑‍⚖️👩‍⚖️\n\n#### (we recommend to read this entire README though :D)\n\nTechnologies implemented here, links go directly to code line on files:\n\n- **`Chainlink Functions`**: [eth-PromptFighters.sol](./src/backend/contracts/nft-contracts/eth-PromptFightersNft.sol#L194), [FightExecutor.sol](./src/backend/contracts/fight-contracts/FightExecutor.sol#L139)\n- **`Chainlink CCIP`**: [CcipNftBridge.sol](./src/backend/contracts/CcipNftBridge.sol#L116)\n- **`Chainlink Automation`**: [FightMatchmaker.sol](./src/backend/contracts/fight-contracts/FightMatchmaker.sol#L340)\n- **`Chainlink VRF`**: [FightExecutor.sol](./src/backend/contracts/fight-contracts/FightExecutor.sol#L164)\n- **`The Graph`**: [Subgraph](./src/subgraph/)\n- **`AI related`**: [mintFighter.js](./src/backend/script/chainlinkFunctionsScripts/mintFigther.js#L56), [fightings.js](./src/backend/script/chainlinkFunctionsScripts/figthings.js#L43), [validateNftPrompt](./src/prompts/nft-generation.txt), [fightGenerationPrompt](./src/prompts/fight-generation.txt)\n\n\u003cdetails\u003e \u003csummary\u003e What each technology brings to the table 🧑‍💻 🆕 \u003c/summary\u003e\n\n#### Read technical details and see architecture diagrams at [docs](./docs).\n\n#### **_`Tech's Utility`_**\n\n- **Chainlink VRF**: deciding fair winners\n- **Chainlink CCIP**: automating process in cheaper chains. (**_Like Avalanche_**)\n- **Chainlink Functions**: Calling APIs to generate NFTs and make them fight in amazing scenarios.\n- **Chainlink Automation** (up-keeps): Automating the fight process for those who have no time to play but some time in the night to read the amazing fight stories before sleep.\n- **OpenAI - APIs**: To generate interesting fight stories and NFT images.\n- **The Graph Indexer**: for cheaper, faster matchmaking and events tracking in website.\n\n#### Check the full-stack source code at [src](./src)\n\n\u003c/details\u003e\n\n---\n\n## `A Message for Chainlink` 💌\n\nDuring our project's development, we detected and thought of potential enhancements and problems using Chainlink Services, particularly Chainlink Functions and Chainlink CCIP.\n\n\u003cdetails\u003e \u003csummary\u003e 💌 \u003c/summary\u003e\n\n#### Key Features for Consideration:\n\n1. Library support in Deno files, especially for hashing (notably keccak256) and asymmetric encryption (ECDSA). Additionally, the addition of a library that simplifies the retrieval of logs from previous blocks would have helped a lot in optimizing and scaling the automated matchmaking and fight system while keeping costs low.\n\n   Practical Application:\n\n   - In our project, implementing hashing would enable private, unique NFT prompts. Currently, NFT prompts are public, allowing duplication. Hashing prompts in Function scripts would allow on-chain storage of hashes and off-chain verification of prompt ownership by the DON, improving privacy and reducing NFT creation costs.\n\n2. Allow for longer HTTP-API calls. AIs that generate images or a bit long outputs like stories take more than the current limit of 9s. Thus we had to mock in Funtions a response simulating an actual AI-API call. Regardless of this the code that would be used if this restriction didn't exist is added in the project.\n\n3. A tool for simulating DONs reponses in local with forked Chainlink contracts would be very helpful for easier debugging and testing.\n   We don't know if this tool already exists, but we think it would be very useful. Whether an SDK or a UI app on chainlink's website.\n\n#### Challenges and errors encountered:\n\nWith **_`CCIP`_**:\n\n1. Difficulty integrating CCIP with `forge`-based projects.\n2. Variable clash (`i_router`) when using Functions and CCIP concurrently.\n3. Non-virtual `supportsInterface()` function in `CCIPReceiver.sol`, creating inheritance conflicts in contrats that inherit different contracts using the EIP-165. (e.g., [eth-PromptFightersNFT.sol](./src/backend/contracts/nft-contracts/eth-PromptFightersNft.sol#L271)). Also `supportsInterface()` is defined as `pure` and when mixed with other `supportsInterface()`\n   functions like ERC721 OpenZeppelin's implementation creates a conflict as OZ's one is `view`.\n\nWith **`Automation`**:\n\n1. We have automation coded in our project but it is only working if upkeep is registered via UI. We don't know whats wrong with our registration code everything looks fine. It's a weird error explained in [this file on scripts directory.](./src/backend/script/AutomationIssue.md).\n\n\u003e 📘**Note**ℹ️: The whole team met in the **SmartCon 2023**, thanks for the great event and the chairs! 😄\n\n\u003c/details\u003e\n\n---\n\n---\n\n## `Deep dive details` 💻\n\n\u003cdetails\u003e \u003csummary\u003e Mechanics 📜 \u003c/summary\u003e\n\n#### Read the details of all mechanics, future scenarios, and its reason why at [whitepaper](./docs/whitepaper.md).\n\n#### **_`Mechanics Implemented`_**\n\n- **Personalized NFTs** : describe your NFT as you want over a template.\n- **NFT creation AI filtered** : so there are no too powerful or copyright infringement prompts.\n- **Fight and bet against other NFTs**.\n- **Automated Fighting** : send some funds and enjoy the fight automation.\n\n\u003c/details\u003e\n\n---\n\n---\n\n## `LOCAL-USAGE` 🌐-⚙️\n\n\u003cdetails\u003e \u003csummary\u003e Local set-up ⚙️ \u003c/summary\u003e\n\n\u003cbr/\u003e\n\n1. **Clone the Repository**\n\n```bash\ngit clone https://github.com/CarlosAlegreUr/ConstellationChainlinkHackathon2023.git\n```\n\n2. **Initialize foundry, forge and dependencies**\n\n```bash\ncd ./ConstellationChainlinkHackathon2023/src/backend\nfoundryup\nforge init --force --no-commit\nforge install --no-commit OpenZeppelin/openzeppelin-contracts@932fddf69a699a9a80fd2396fd1a2ab91cdda123\n\nforge install --no-commit smartcontractkit/chainlink@cdb0c6a6089d3a69dd09a9b0a9fbdd070eaeb442\n\n# Chainlink ccip contracts cant be installed with forge\n\n# Use this to install CCIP contracts in \"./src/backend\" (you should already be here)\n\n# Just leave everythin empty and press enter\ncd lib\nnpm init\nnpm install @chainlink/contracts-ccip --save\n\n# Change the name to node_modules_ccip\nmv ./node_modules ./node_modules_ccip\n\n# Notice ℹ️ you can remove package.jon and package-lock.json\n# if you want.\n```\n\n**_The /lib directory should now look like this:_**\n\n\u003cimg src=\"./repo-images/lib-example.png\"\u003e\n\n\u003cbr/\u003e\n\n\u003e **Note ⚠️** Current Chainlink Functions only allows for 9s long HTTP-API calls. Our fight generation requires more than 9s thus we have mocked in the backend a node from a DON executing Chainlink Functions. Functions for NFT validation does work and is implemented interacting with the real DON.\n\nRun the DON mock:\n\nThe DON mocker that listens for figths is a scripts\nthat's found inside next.js project, inside the folder `figthListener`\n\n*First* construct the .env\n\n```bash\ncd src/prompt-figthers/figth-listener/\n\n```\n\n\nInside this folder you will find an `example.env`\n\nCreate an `.env` with the values required\n\n```bash\n# create the env file\ntouch .env\n\n# edit it with the best text editor ever\nnvim .env \n```\n\nAnd now we can run the script\n```bash\n# root of next.js project\ncd ../..\n\n# This requires node\nnpm run donMock\n\n```\n\n\n\n4. **Running the Frontend**\n\nAll the backend is ready to so now execute the front-end\nlocally:\n\n```bash\n# cd to the front end directory\ncd src/prompt-fighters\n\nyarn install\n\nyarn dev\n```\n\n---\n\n## Run Scripts locally to see how all interacts iteratively 🏗️🏛️\n\nRun scripts' instructions in here: [scripts](./src/backend/script).\n\n---\n\n## Run Tests 🤖\n\nRun tests' instructions in here: [tests](./src/backend/test).\n\n---\n\n\u003c/details\u003e\n\n\n---\n\n# `Spam ;D` 📧\n\n3 of us are seeking for job opportunities inside the blockchain world. If you have any for us we would be very happy to hear from you.\n\n- **`Carlos Alegre`**: Full-stack developer and auditor\n  [Github](https://github.com/CarlosAlegreUr) | [Linked-In](https://www.linkedin.com/in/carlos-alegre-urquiz%C3%BA-0b19701b3/)\n\n- **`Antonio Rodríguez-Ynyesto`** Full-stack developer mainly interested in Smart Contracts.\n  [Github](https://github.com/arynyestos) | [Linked-In](https://www.linkedin.com/in/antonio-maria-rodriguez-ynyesto-sanchez/)\n\n- **`Ethan Rouimi`** Full-stack developer and a web3 fanatic.\n  [Github](https://github.com/Ethanol48) | [Linked-In](https://www.linkedin.com/in/ethan-rouimi/)\n\n  \n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlosalegreur%2Fconstellation-chainlinkhackathon-2023","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarlosalegreur%2Fconstellation-chainlinkhackathon-2023","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlosalegreur%2Fconstellation-chainlinkhackathon-2023/lists"}