TypeScript Smart Contract 101 Challenge
Do you often find yourself asking, βWhy did my once-thriving plant suddenly turn into a sad pile of leaves?β If so, youβre not alone! Many of us have been there β overwatering, underwatering, or simply forgetting to check on our leafy companions. But donβt worry, Plant Manager is here to save the day (and your plants)! π±π· It's your personal plant assistant, designed to help you keep your plants healthy and happy.
- Add a New Plant π»: Got a new plant? Add it to your garden and keep track of its needs.
- Retrieve Plants π±: See all your green friends in one place.
- Update Plant Details β¨: Changed the plantβs name or want to add extra notes? No problem.
- Delete a Plant πͺ΄: Time to say goodbye? Remove plants from your collection when needed.
- Check Plants Needing Watering π§οΈ: Find out which plants are giving you the sad eye and need a drink.
- Water a Specific Plant π¦: Update the watering status for your plants and keep them hydrated!
- Clone the repository.
- Install dependencies using
npm install
. - Run the project using
dfx start --host 127.0.0.1:8000 --clean --background
thendfx deploy
.
Once the project is running, you can make HTTP requests to the exposed endpoints to interact with your garden.
-
POST /plants
: Add a new plant to your garden.- Request Body:
{ "name": "Rose", "species": "Rosa", "waterFrequencyDays": 7, "notes": "Needs a lot of sunlight." }
- Example Request:
curl -X POST http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/plants -H "Content-Type: application/json" -d '{"name": "Rose", "species": "Rosa","waterFrequencyDays": 7, "notes": "Needs a lot of sunlight."}'
- Request Body:
-
GET /plants
: Retrieve a list of all plants in your garden.- Example Request:
curl -X GET http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/plants
- Example Request:
-
GET /plants/:id
: Retrieve details of a specific plant by ID.- Example Request:
curl -X GET http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/plants/{plantId}
- Example Request:
-
PUT /plants/:id
: Update details of a specific plant by ID.- Request Body:
{ "name": "Rose π₯" }
- Example Request:
curl -X PUT http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/plants/{plantId} -H "Content-Type: application/json" -d '{"name": "Rose π₯"}'
- Request Body:
-
DELETE /plants/:id
: Delete a specific plant from your garden by ID.- Example Request:
curl -X DELETE http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/plants/{plantId}
- Example Request:
-
GET /plants/need-watering
: Check which plants need watering.- Example Request:
curl -X GET http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/plants/need-watering
- Example Request:
-
PUT /plants/:id/water
: Update the last watered date for a specific plant by ID.- Example Request:
curl -X PUT http://bkyz2-fmaaa-aaaaa-qaaaq-cai.localhost:8000/plants/{plantId}/water
- Example Request: