Megaverse Grid Manager is a Node.js project that automates interactions with the Crossmint API to manage entities within a grid-based system. It clears existing grid entities like POLYanets, SOLoons, and comETHs, and creates new ones based on a predefined goal map retrieved from the API.
- Clear Grid: Removes all existing POLYanets, SOLoons, and comETHs.
- Populate Grid: Fills the grid with entities based on the retrieved goal map.
- Optimized Iteration: Custom logic to intelligently skip "SPACE" entities during both creation and deletion phases, significantly reducing processing time and improving overall efficiency.
- Rate Limiting Management: Handles delays to avoid hitting API rate limits.
- Retry Logic: Implements retry mechanisms for handling rate limit errors (HTTP 429).
- Logging: Provides logs for progress tracking, including creation and deletion of entities.
Ensure you have the following before running the project:
- Node.js installed (Node.js Official Site)
- npm installed (comes with Node.js)
- Candidate ID
git clone https://github.com/Cryptolyfe/Megaverse_Grid_Manager.git
cd Megaverse_Grid_Manager
npm install
touch .env
CANDIDATE_ID=your-candidate-id-here
The project uses a single script (index.js) to both clear the existing grid and populate it with new entities based on the goal map.
Run the script:
node index.js
Starting the process to build the goal map.
Clearing the grid...
Skipping entire row 0 during clearing, as it contains only 'SPACE'
Deleted COMETHS at (1, 7)
Deleted POLYANETS at (2, 2)
Deleted POLYANETS at (2, 3)
Deleted COMETHS at (2, 13)
Deleted POLYANETS at (2, 23)
...
Skipping entire row 29 as it contains only 'SPACE'
Goal map created successfully.
Process completed successfully.
-Clears the grid of all existing entities by deleting POLYanets, SOLoons, and comETHs.
-Introduces a delay to prevent hitting API rate limits.
-Implements retry logic for rate-limiting (HTTP 429) errors.
-Populates the grid with new entities from the goal map retrieved from the API.
-
Separation of Concerns (Modularization) Improvement: Separate the functionality into dedicated scripts: -index.js
-utils.js
-clear.js: Dedicated to clearing the grid.
-create.js: Dedicated to creating the entities.
Why: Modular scripts will improve maintainability and allow for more flexible testing and troubleshooting. -
Optimize the Rate Limiting Delay Improvement: Experiment with shorter delays between API calls (currently set at 500ms for deletions and 1000ms for creations) to find the optimal balance between speed and avoiding rate limits.