We love online food delivery. You pick your phone and pick up your favorite dish from the menu, then place the order, the food magically appears at your doorstep (sometimes we have to provide directions for the delivery executive, but it's ok). We are ready to pay a couple of extra bucks. We are ready to pay a little bit extra to get the food delivered. It could be in the form of delivery fees or something else.
Some of the popular food delivery platforms are Zomato/Swiggy. We know what they are known for. But decentralizing such applications is no easy feat.
Some time ago when I started exploring blockchains, crypto, NFT, I started thinking about applications that can be decentralized. I had a very hard time coming up with a solution to decentralize Swiggy. When we think of how Swiggy works in a centralized world, there are 2 major phases. The first phase is that we place an order. The second phase is when the food is delivered by the delivery executive.
This is similar to decentralizing any other application using a centralized database. First, we have to replace the centralized database with a blockchain. It might be tempting to store all the information about the restaurant and their food on a blockchain. But there is a problem, storing information on a blockchain is very expensive. Also, food prices keep changing from time to time, so storing volatile data on a blockchain is not a good idea. We have to store these data on a centralized database.
And we need a user interface for the users. This application is to be served from a centralized server. Even the most popular web3 applications like UNISWAP, server their user interface from a centralized server. We can fetch the data from the centralized database about the restaurant and show it to the customer
The orders should be placed using a smart contract by the customers. Customers need not worry about this, it will take place automatically in the user application when they place the order. Since we won't be using fiat currency in the blockchain world, we need to invent an ERC20 token specifically for this purpose. Let's call it the 'ZOM' token. Users need to have ZOM tokens in their wallets to place an order.
After the order is placed, the token will be credited into the restaurant’s wallet. We’ll talk about the incentive part for the delivery executive later. For now, remember the total cost to place the order is “Price of the food“ + “incentive for the delivery executive“.
Since the user interaction is pseudonymous (you can only see their public address, not their identity) in a decentralized world, we don’t have to save any information about the user. Every order we place will be registered as a transaction in blockchain or smart contract like in any other blockchain application.
Keeping these things in mind, now the user can use the mobile app to order food. This transaction will be registered in the blockchain/smart contract. The restaurant will have a separate application from which they retrieve data from the blockchain and prepare the food. The restaurant doesn’t care about where the food has to be delivered. They prepare for food and leave the rest to the delivery executive.
Now that the food is prepared. The only part left is for the delivery executive to pick up the food and deliver it to the customer. We need a separate application for the delivery executive using which one can confirm that they are going to pick up food from a particular restaurant.
Now let’s come to the incentives the delivery executive gets. After all, they deliver you food because they know they get paid in the centralized world. One way to incentivize them is by using the ERC20 token (ZOM token in this case). Whenever the user places an order they can set how much they are willing to pay the delivery executive with this token.
The delivery executive can then decide whether to pick up the order depending on the distance they have to travel to deliver the order concerning token incentive. Only after the customer has confirmed the order delivery, the delivery executive will receive their incentive in the form of a token. This is to make sure that the delivery executive is paid only after the customer is satisfied.
This is one of the ways to decentralize Swiggy/Zomato. As we saw earlier, it is not a perfectly decentralized application. There is some centralized part involved. Even though we are getting too much excited about the decentralization, some parts of our day-to-day activities will be centralized. I believe in the future, both centralization and decentralization will coexist.