Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
/ eggChain_DApp Public archive

A Decentralized Application based on Ethereum Blockchain to track egg shipments from the place of production to the final destination of sale.

License

Notifications You must be signed in to change notification settings

Abhinav-ark/eggChain_DApp

Repository files navigation

eggChain Decentralized App


EggChain is a Decentralized Application based on Ethereum Blockchain to track egg shipments from the place of production to the final destination of sale.

Every transaction is public to the consumer, to view the entire history of every single trasaction in the supply chain.

Tech Stack

Features

  • Creation of Shipments, one at a time or multiple entries at a time using JSON file format.
  • Starting the Shipment from the Sender to Receiver.
  • Receive and Pay in Ether for shipments at Receiver's End
  • Wallet based authentication to ensure, only the owner of a shipment can perform operations on it.
  • Looking up Current Shipment Status & Details By ID.
  • Search for shipments based on containerId, sender address and receiver address.

Interacting with the Decentralized Application


This is the Home dashboard of the eggChain DApp which offers multiple services: Create Shipment, Start Shipment, Complete Shipment, Send Shipment, All Shipment, Get Shipment, Profile

Creating A Shipment

  1. Click on Add Tracking to open the Create Shipment Dialog Box, Fill the Details and Click on Create Shipment .


2. Pay the Gas Fees to proceed with the Transaction


  1. You will get a Transaction Successful Alert if the Transaction was successful.


  1. You can Alternatively Create Multiple Shipments by uploading a JSON file in the prescribed format, Click on Use JSON File Button, In the Create Shipment Dialog Box.



This the The Updated Transactions Table After Creating the Shipments.


Starting A Shipment

Enter the receiver wallet address, shipmentId, start the shipment and pay the gas fee. You should see the status of the Shipment become IN_TRANSIT in the Shipments Table.


Completing A Shipment

Enter the receiver wallet address, shipmentId, start the shipment and pay the (gas fee + shipment amount). You should see the status of the Shipment become DELIVERED and the Delivery date updated to the current date in the Shipments Table.


Sending A Received Shipment

  1. Change your Metamask account to an account which is a receiver of any delivered shipment. Here I am changing it to Account 4.

  1. Enter the receiver of the new shipment, the container you want to transfer, pickup date, distance and price in Ether. Click on Send Shipment and pay the gas fee to proceed.

Searching The History Of A Container

The All Shipments Table section of the dashboard has a search that helps to search shipments by sender address, receiver address and containerId which plays an instrumental role is seeing all shipments sent by a user, seeing all shipments received by a user and the whole supply chain life cycle of a container shipment.


Get Details Of A Specific Shipment

Enter the shipmentId of a shipment to see data regarding it's current status.


Total Shipments On the Supply Chain Network

You can see the total number of Shipments that happened on the supply chain till now.


Profile (If logged in using wallet)

You can the the user's wallet balance and total no. of shipment made by the user till date.

How to Run the DApp

  • Either clone the repository (or) download the Source Code from the latest release.
  • Make sure you have nodeJS installed on your Computer (Node 20 LTS is recommended).
  • Run this command from the parent directory, to install all dependencies.
> npm install --force
  • Run a local hardhat node.
> npx hardhat node
  • A JSON RPC Server is started in your localhost:8545 and you get 20 Accounts with 10000 Eth. in each account.
  • Create a new terminal instance and deploy the smart contract to the local network.
> npx hardhat ignition deploy ignition/modules/Tracking.js --network localhost

Important

Run npx hardhat clean and npx hardhat compile to clean the artifacts of the previous smart contract and compile the new one, whenever you modify the smart contract.

  • Create a .env file to enter the contract address you got in the previous step as an Environmental Variable.
  • Start a local NextJS development server.
> npm run dev
  • You can access the DApp from http://localhost:3000 in your Google Chrome Browser.

  • Install Metamask wallet extension for Google Chrome.

  • Login to your Metamask Wallet

  • Add and connect to the local Ethereum network. Settings > Networks > Add A Network > Add a network manually

  • Add any accounts to the Metamask Wallet from the 20 you got after running the hardhat node. Goto Add account > Import Account. Enter the private key of the account you want to import and click on Import.

  • You can interact with the DApp now after logging in to an Account on the network.

Warning

If you transactions keep failing and you get a MetaMask - RPC Error: Internal JSON-RPC error on the console, It is most likely due to an Issue with Metamask. In that Case goto Settings > Advanced and click on Clear activity tab data and try again.


Contributing

Refer to The Code of Conduct before making a pull request to the repository, posting on the discussions section or involing in any public activity related to this repository.

Security Policy

Refer SECURITY.md for Security Policy.

Attributions

  • Start Shipment Icon : Product icons created by Freepik - Flaticon
  • Send Shipment Icon : Delivery icons created by Freepik - Flaticon
  • Complete Shipment Icon : Delivery icons created by Freepik - Flaticon
  • Get Shipment Icon : Search icons created by Maxim Basinski Premium - Flaticon
  • User Profile Icon : User icons created by Freepik - Flaticon
  • Shipment Count Icon : Counting icons created by smashingstocks - Flaticon

Licensing

All code in this repository is Licensed Under MIT License, and is freely available for anyone to use or make changes.