How to build Decentralized RideSharing – Part 1

Decentralized RideSharing platform can connect drivers directly with passengers via instant P2P protocol.

Here are the contents of this tutorial:
Part 1: Decentralized Ridesharing – Solution
Part 2: Decentralized Ridesharing – Creating smart contract
Part 3: Decentralized Ridesharing – Building DApp
Part 4: Decentralized Ridesharing – Deploying on blockchain

In this part, we’ll go through following points

  • Centralized Ridesharing concerns
  • Decentralized Ridesharing solution
  • Solving Booking Use Cases
  • DApp Architecture
  • Demo

Ready? Let’s start…

Centralized RideSharing concerns

  • High fees due to middleman: the ridesharing companies likes Uber,
    Lift and Grab could charge 10-30 percent of the total passenger’s pricing, costing high to the customers. Therefore, the involvement of intermediaries between a driver and a passenger will lead to increase costs.
  • Lack of transparency: if you have ever used ridesharing services, you must have faced a problem of surge pricing. Passengers don’t have a clear understanding of the reason behind the sudden price rise. Or another problem – driver’s rating, the company can cheat data completely if they want.
  • Lack of safety: one of the most important issues is the concern about the safety of both passengers and drivers. Taxi organizations are spending millions of dollars to verify users. But despite efforts, identities and criminal still exist.

Decentralized RideSharing solution

By moving from centralized platform to decentralized platform, taking advantages of the Blockchain, using Smart Contract so that:

  • Getting middleman out of the game, passengers pay less, drivers are paid more.
  • Drivers and passengers control the transactions, own the data, and transact securely through a peer-to-peer network.
  • All data transparent, no one can modify or cheat data.

In this tutorial, we’ll build a DApp and use Smart Contract on Blockchain to solve the concerns above.

Solving Booking Use Cases

In this tutorial, I want to show you to how to solve basic use cases as below

  1. Passenger creates a booking
    • New booking is created with trip info (passenger info, location origin/destination, distance, cost…)
    • Tokens (cost) will be transferred from passenger’s wallet to smart contract.
  2. Driver accepts a booking
  3. Passenger cancels a booking
    • Cost will be refunded from smart contract.
    • Booking is cancelled.
  4. Passenger completes a booking
    • Tokens (cost) will be transferred from smart contract to driver’s wallet.
    • Booking is completed.

DApp Architecture

We’ll be using the following tech stack to develop our application.

  • DApp: Decentralized Applications are applications that run on a P2P network of computers. If an App = frontend + server, since Ethereum contracts are code that runs on the global Ethereum decentralized peer-to-peer network, then: DApp = frontend + contracts
  • IPFS: IPFS stands for InterPlanetary File System. It’s a protocol designed to create a permanent and fully decentralized method to store and share files. A decentralized app should be hosted on decentralized storage.
  • Ethereum: Ethereum is an open-source, public, blockchain-based distributed computing platform and operating system featuring smart contract (scripting) functionality.
  • Web3.js: collection of libraries which allow you to interact with a local or remote ethereum node, using a HTTP or IPC connection.
  • Metamask: is a bridge that allows you to visit the distributed web of tomorrow in your browser today. It allows you to run Ethereum dApps right in your browser without running a full Ethereum node.
  • React/Angular: front-end javascript library/framework to develop web app.

Demo

Below is demo running on GoChain TestNet. You can develop on Ethereum of course, but I want to deploy on GoChain because it’s a scalable, Ethereum based smart contract blockchain that is fast, secure and 100x increased performance .

Demo on GoChain TestNet