Complete Supply Chain App Development on Ethereum Blockchain Test Network (Ropsten)

Supply Chain App Development on Ethereum Blockchain
Supply Chain App Development on Ethereum Blockchain

Blockchain

Complete Supply Chain App Development on Ethereum Blockchain Test Network (Ropsten)

How do you know that the coffee that you brought is actually fair trade? How do you know which one is real? How do you know that a t-shirt has not been made in a sweatshop and a simple tag added at the end? You simply don’t.

In order for you to be certain – you would need a record of all transactions and event of the life of an item, that would be possible with Blockchain and what’s the Blockchain? That’s a fancy word; Blockchain is related to Bitcoin – the cryptocurrency. Initially it was made for financial transactions but it is now revolutionizing the business world especially Supply Chain, it’s just like Google sheet with regular transaction there is a middleman like the bank that registers this transaction – a centralized system like Microsoft Word but the Bitcoin transactions are between user to user so when there’s a transaction the information is recorded in a shared ledger or block and these blocks are linked together to form a block like a shared Google Doc.

Transaction accuracy is driven by the fact that consensus creates truth and a Blockchain database every participant or node maintains a copy of the shared ledger. Each transaction on the Blockchain is recorded in computer code showing that who the parties are, transaction details and timestamp with each containing their unique math based encrypted signature. This digital signature is key as it allows each block of information to be securely connected to all the rest. It’s this system of fully transparency and connectedness that lends the Blockchain its trust and credibility. This connection provides an audit trail of every transaction that’s ever occurred in a system, so if there were an unauthorized change each node is notified and we can see where it took place they then will agree to recognize the change as valid or rejected. Again transparency and consensus combine to make the Blockchain system virtually tamper proof.

Today your data will be stored publicly or pseudo anonymously in a shared database. Now with Blockchain you can track the chronological history of the organic cotton shirt that you bought, you cannot tamper or cheat because everyone using the system is watching you.

So here is how you can create your own supply chain network to track your products on each node.

Use Case:

  • This system will track the movement of smart phones from PORT-A to PORT-C, below are the conditions
    • At PORT-A basic information about smart phone is added
    • You are not allowed to send locked mobile phones from PORT-A to PORT-B
    • QMobiles are not allowed to move from PORT-B to PORT-C

Pre requisites:

Meta Mask Settings:

Click on the Meta mask icon from the extension area of chrome browser and follow the steps below.

  • Create an account on Meta mask and choose a password.

  • Set your network to ROPSTEN Test Network.

  • Create ROPSTEN Ethereum Test Network account.

  • Now buy some Ether – You can also click on BUY in your Meta Mask Ropsten Account.

 

Smart Contract:

Blockchain software code representing an arrangement or a contract that the computer can make and execute automatically under conditions set in advance and not just a single agreement but bundles of contracts linked to each other all operating autonomously and automatically. Smart contracts will build under solidity language (.sol) and we use Remix IDE to create for supply chain.

Open Remix IDE on chrome browser with meta mask installed and add following solidity code into it.

Now click on create and make sure that Environment is set to “Injected Web3” like showing in the image below.

When create button is clicked Meta mask will automatically opens and let you confirm the transaction. Click on submit to confirm.

Now go to https://ropsten.etherscan.io and add your account number inside the top right search textbox, you will see all transaction details and at the top – your current contract information will be shown.

To get all the transaction details click on TxHash of your following transaction.

Copy contract address, we will use this in our project for interacting with our contract, in this case the Contract address is “0xaf3155786afa67f796c9a93738f6af92d37f6c46” – also highlighted in the image below.

That’s it we have successfully created and deployed our contract to “Ropsten Test Ethereum Network”.

Frontend:

For the frontend we will be creating three separate projects (PORT_A, PORT_B & PORT_C) in our local server (I’m using XAMPP).

PORT_A

Create a project/folder “PORT_A” and import web3.min.js file in your project folder and then create a new PHP file name it “index.php” and put the following code in it.

Index.php

Copy ABI ARRAY by navigating details of your contract from Remix IDE.

PORT_B

index.php

PORT_C

index.php

Note: web3.min.js is required for all three PORTS.

 

Results:

Now run these in three different tabs, browsers or you can run them on three different systems as well.

PORT-A :- enter your smart phone details and hit submit you will see meta mask will popup to confirm the transaction hit submit and your information will be stored on ethereum test blockchain.

PORT-B :- click “get Inspection Result” you will see that your data will popup which you had sent from PORT-A, Now click on “inspect” (check for QMobile) and then click again on get Inspection Result – Because the smart phone is not a QMobile it will authorized for sending to PORT-C.

PORT-C :- when mobile received at PORT-C it will be confirmed by clicking on “confirm” button and then status will be updated.

Click on Get Delivery Status:

So, this is how Blockchain is implemented in Supply Chain. If you have any question feel free to ask in the comment section below.

I am a Sr. Android App & Web Developer having 5 plus years of extensive hands-on experience in Object Oriented Programming, Database Design and Implementation using Agile & UML. Pro in Yii2 PHP Framework, Android App Development, MYSQL & a Blockchain enthusiast.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

More in Blockchain

Recent Posts

Categories

Tags

To Top