Inspiration
Food wastage is an widely apparent issue around the world. On a daily basis, food in many restaurants is often thrown out in large quantities, which results in immense food wastage. More than 80% of food is wasted in the US alone... the global numbers must be frightening! What if there was a way to drastically reduce food wastage? What if this food could be used before it gets expired and thrown out? That's where Save It comes in.
What it does
Save It lets food companies and organizations donate their unsold food before it expires and gets tossed out. This food will be transported and distributed to people in need. The transportation and distribution of this food will be funded by donators who donate to the smart contract.
Donators automatically get entered into a decentralized lottery and a random winner gets selected every month. And the prize? One of the food places who have offered to donate food will be randomly picked for their food to be delivered to the winner.
How we built it
The entire dapp consists of 3 main building blocks. We call this Donate, PickUp, and Lottery. The smart contract and the front end were designed around these 3 building blocks.
Donate The first step in saving the food is to donate funds that can support the packaging and transportation of food from restaurants. A donate function was designed to allow users to send ETH to the smart contract and if the users had not previously donated, the function would register the user as a new donator. The minimum donation amount was set as 10 USD. The Chainlink PriceFeeds oracle was used to get the conversion rate between ETH and USD so the user can donate an amount of ETH that corresponds to 10 USD.
PickUp The second step is to use the donations to pick up and transport the food from the restaurants to the donation area where people in need can collect it. A registered restaurant could set their name and location using the smart contract functions provided. A function was created in the smart contract for restaurants to request a delivery by specifying the amount of food in kilograms to be transported. A cost of 25 USD was set as a placeholder value for transporting the food as it is a good average cost for the transportation of services. After the restaurant requests a delivery, the smart contract would automatically fund the delivery on the prerequisite that there were enough donations made to the smart contract.
Lottery The lottery aspect of the smart contract is largely inspired by Patrick Collin's smart contract lottery (repo: https://github.com/PatrickAlphaC/hardhat-smartcontract-lottery-fcc ) with a few minor tweaks. Instead of entering the raffle with an entrance fee, users who donate are automatically entered into the lottery. The more donations they make, the more entries they have and a higher chance to win. And what's the winning prize? That's right, free food! A random winner will be awarded food which will be delivered from a randomly selected restaurant. This randomness will be decided using Chainlink's verifiable random function (VRF) and Chainlink keepers for triggering the lottery every month.
FrontEnd: Putting it all together A simple front end was created for users to interact with the smart contract. The main page of interaction is the donate page which holds the "Donate ETH" and "Donate Food" options. Users can fund food donations by donating ETH by using the first option. If a restaurant chooses to donate food, they can do so by choosing the second option and specifying the amount of food in kilograms. The lottery page displays the previous month's winner and the selected restaurant which will delivery free food to them.
Setup: How to run the app
Git clone the project by running the following command in your terminal
git clone https://github.com/rk119/Save-It
Once this is complete, change directory into the Save-It directory and install all the necessary dependencies. The package manager we used is yarn but any package manager will do.
yarn
Make sure all the solidity files have been compiled and then run the local blockchain
yarn hardhat compile
yarn hardhat node
Upon running the local blockchain, the smart contracts should be deployed. Copy the address to which SaveIt was deployed to and paste it in src/contractinfo/addresses.js
Start up the app with the following command
yarn start
Ensure the network is set to the local host on metamask.
Challenges we ran into
Lack of prior experience in building full-scale projects, inconsistent time management.
Accomplishments that we're proud of
Despite being complete beginners with no prior knowledge in blockchain, creating smart contracts, building full stack applications, a small Dapp was still created.
What we learned
Basic knowledge was gained in blockchain, smart contracts, testing frameworks, collaborating on GitHub, using Moralis, building simple web applications, and using web framework tools,
What's next for Save It!
Depending on how things go, Save It may make a comeback with a full-scale implementation. Save It is a thought, an idea, an enigma. Its purpose is to inspire and instill hope in the hearts of those who believe the world can still become a better place. What are you going to do with that left over food? Let's Save It!
Built With
- bootstrap
- chainlink
- css
- ethers
- hardhat
- javascript
- moralis
- react
- solidity

Log in or sign up for Devpost to join the conversation.