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
.
- 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
inEther
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.
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
- Click on
Add Tracking
to open the Create Shipment Dialog Box, Fill the Details and Click onCreate Shipment
.
2. Pay the Gas Fees to proceed with the Transaction
- You will get a
Transaction Successful
Alert if the Transaction was successful.
- You can Alternatively Create Multiple Shipments by uploading a JSON file in the prescribed format, Click on
Use JSON File
Button, In theCreate Shipment
Dialog Box.
This the The Updated Transactions Table After Creating the Shipments.
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.
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.
- Change your
Metamask account
to an account which is a receiver of any delivered shipment. Here I am changing it to Account 4.
- 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.
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.
Enter the shipmentId of a shipment to see data regarding it's current status.
You can see the total number of Shipments that happened on the supply chain till now.
You can the the user's wallet balance and total no. of shipment made by the user till date.
- 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 yourGoogle 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.
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.
Refer SECURITY.md for Security Policy.
Start Shipment Icon
: Product icons created by Freepik - FlaticonSend Shipment Icon
: Delivery icons created by Freepik - FlaticonComplete Shipment Icon
: Delivery icons created by Freepik - FlaticonGet Shipment Icon
: Search icons created by Maxim Basinski Premium - FlaticonUser Profile Icon
: User icons created by Freepik - FlaticonShipment Count Icon
: Counting icons created by smashingstocks - Flaticon
All code in this repository is Licensed Under MIT License
, and is freely available for anyone to use or make changes.