VIETNAM-KOREA UNIVERSITY OF INFORMATION ANDCOMMUNICATION TECHNOLOGY Faculty of Computer Science GRADUATION PROJECTTOPIC: THE ACTUAL PROJECT OFCONSTRUCTING THE E-COMMERCE WEBSITE... ACKNO
Trang 1VIETNAM-KOREA UNIVERSITY OF INFORMATION AND
COMMUNICATION TECHNOLOGY
Faculty of Computer Science
GRADUATION PROJECTTOPIC: THE ACTUAL PROJECT OFCONSTRUCTING THE E-COMMERCE WEBSITE
Trang 2VIETNAM-KOREA UNIVERSITY OF INFORMATION ANDCOMMUNICATION TECHNOLOGY
Faculty of Computer Science
GRADUATION THESIS
CONSTRUCTING THE E-COMMERCE WEBSITE
Trang 5ACKNOWLEDGEMENTS
In order to carry out and complete the project well, we have received the help andguidance of the teachers from the Vietnam - Korea University of Information andCommunication Technology - the University of Danang I would like to thank theteachers of the specialized subjects for providing them with valuable and necessaryinformation during the time so that I could make and complete my map In particular, Iwould like to sincerely thank Mrs TRINH THI NGOC LINH who directly guided meduring the implementation of this thesis
Furthermore, we would like to express our profound gratitude to DanawebCompany in the information technology industry, who have consistently supported,assisted, shared knowledge, experience, and provided valuable materials that aided usthroughout our research and thesis implementation
Due to the limitation of time and knowledge as well as practical experience, thethesis cannot avoid errors I look forward to receiving your understanding and lookingforward to receiving your suggestions and comments
Thank you sincerely!
Da Nang, December 2023
Students
Nguyen Xuan Linh
4
Trang 6STATEMENT OF AUTHORSHIP
I here by declare that I am the sole author of this bachelor thesis and that I havenot used any sources other than those listed in the bibliography and identified asreferences I further declare that I have not submitted this thesis at any other institutionin order to obtain a degree
Da Nang, December, 2023
Nguyen Xuan Linh
5
Trang 76
Trang 83.1 Blockchain technology in agricultural product traceability153.2 Blockchain technology application in Products traceability16
Trang 9ABBREVIATIONS ABBREVIATION
Trang 10Image 10 How Blockchain Technology works 214Image 11 How Blockchain Technology works 314Image 12 How Blockchain Technology works 414
9
Trang 11Image 30 Homepage interface18
Image 37 Add products function 1 picture 221
Image 39 Display successful product added message21
Image 50 The Solidity function handles search date22
Image 52 Jquery function show detail product22
10
Trang 12LIST OF TABLES
11
Trang 13INTRODUCTION1 Topic overview
Blockchain is now increasingly widely applied in many industries such asfinance and banking, retail, freight, manufacturing, telecommunications, etc Inagriculture, blockchain has also begun to be applied in source traceability supplychain origin to improve traceability and transparency in the agricultural value chain:
- Update information quickly in real time and connect information In theagricultural supply chain, each participating process from hatchery, feed, medicine,manure, farm, production plant, transportation, distribution, etc is recorded on theblockchain system one by one simple way in real time
- Data is secure and reliable The invulnerability and information security ofblockchain make it of great value in traceability All information put on the networkwill not be changed by anyone because it is confidential and shared by manydifferent people on the system
- Ability to access data quickly The application of blockchain in traceabilityallows data that has been shared on the system to be quickly accessed in real time
Therefore, it is easier to accurately trace back, determine the cause of insecurityand recall products when applying blockchain technology
2 Research purpose, scope and methods.Research purposes.
Successfully built a website to trace the origin of Products products based onBlockchain technology
Research scope.
- Blockchain technology.- RSA encryption.- Research product (Products)
Research Methods.
12
Trang 14- Research on theory and learn about documents.- System analysis and design.
- Build system- Statistical evaluation results- Build the interface for the website- Complete website
- Software Testing.- Write reports and finalize products
3 Content implementation- Chapter 1 : RESEARCH OVERVIEW- Chapter 2 : SYSTEM ANALYSIS AND DESIGN- Chapter 3 : BUILD SYSTEM
- Conclude- References
13
Trang 15CHAPTER 1 RESEARCH OVERVIEW
1.1Introduction to languages and tools1.1.1 Ethereum
Ethereum (ETH) is an open source, public, distributed computing platform basedon Blockchain technology It features a smart contract to facilitate online contractagreements The platform is a fully Turing virtual machine - Ethereum VirtualMachine (EVM), which can execute scripts using a network of ETH computers
Image 1 Ethereum
Since the EVM virtual machine acts as a “world computer” with many nodes, itactually uses many programming languages including C++, Python, Ruby, Go, andJava A specialized language called Solidity is used to write smart contracts in theETH virtual machine
ETH is a generalized Blockchain for everyone to use privately by running thecode of applications generated on ETH Each block of ETH can be viewed as virtualmachines, running operations to store information and data These blocks are createdwhen there are transaction contracts
14
Trang 161.1.2 Web3.js
Web3.js is a collection of libraries that allow developers to interact with a remoteor local Ethereum node using HTTP, IPC, or WebSocket Using this library, you candevelop websites or clients that interact with the blockchain This can be actions likesending Ether from one user to another, checking data from smart contracts, creatingsmart contracts, among other things Ethereum nodes provide interfaces to users inorder to complete transactions: of which, nodes receive this information through aJSON RPC interface This is an encoding format that allows running processes toreceive new and verify existing data Web3.js helps to make the process of runningand selecting nodes participating in the Ethereum network simpler and easier to grasp
Image 2 Web3.js
ReactJS is roughly understood as a library that contains a lot of open sourceJavaScript and the father of ReactJS is a big man with a well-known name that isFacebook The purpose of creating ReactJS was to create attractive web applicationswith high speed and efficiency with minimal coding And the main purpose of ReactJSis that every website when using ReactJS must run smoothly, quickly, and be highlyscalable and simple to implement
1.1.3 Bootstrap
15
Trang 17Bootstrap is pre-written code to help developers easily create website interfacesthat are compatible with mobile screens Bootstrap is a framework that includesHTML templates, CSS templates and JavaScript templates for developing responsivewebsites Bootstrap essentially consists of a set of syntaxes that perform specificfunctions To work properly, Bootstrap needs to have the main files that manage theuser interface and functionality of the website Those are 3 files:
- Bootstrap.css: a CSS framework that organizes and manages the layout of thewebsite To perform a specific action, two structures need to exist at the sametime: HTML manages the content and website structure, and CSS handles thewebsite layout
- Bootstrap.js: This file is the core of Bootstrap Bootstrap.js includes theJavaScript files responsible for the interaction of the web page
- Glyphicons: Associate icons with certain actions and data in the userinterface
Image 3 Bootstrap
Features of Bootstrap
- Allows your website's user interface to work optimally on any screen size.Whether on small screen phones or large screen desktop computers, thewebsite still works stably
- Can integrate with many open source code such as: Joomla, Magento,WordPress thanks to the modular design easily integrates with mostpopular open source codes on the market today such as WordPress, Joomla,
16
Trang 18- Helps users easily manipulate and customize the framework on the websitebefore downloading and using it at the framework's website.
- Integrating jQuery on Bootstrap is simple: just declare the features used inthe web design process
- Support as diverse as slides, responsive, multi-level menus thanks to highcompatibility
17
Trang 19language is very easy to learn for programmers Solidity explains quite well how itscode works for those who are interested and want to learn about this language.However, the explanation can be confusing for those unfamiliar with modernprogramming languages As the new language for Blockchain, Solidity is becomingmore and more popular The increase in the number of courses and resources acrossthe language is a very clear indication of this, and the language is expected to make asignificant contribution to software engineering by improving Blockchain.
Image 5 Solidity
1.1.5 Blockchain
Blockchain is a decentralized database that stores information in blocks that arelinked together by encryption and expanded over time to form a chain Each block inthe Blockchain will be linked to the previous block, containing information about thetime the block was created along with a timecode and transaction data
Simply put, blockchain can be seen as an electronic ledger distributed on avariety of computers, storing all transactional information and ensuring that it cannotbe changed in any way
All information stored on that ledger will be confirmed by a series of computersconnected in a common network No machine will be able to change, overwritten ordelete data in that ledger
18
Trang 20Since blockchain was born to address the limitations in a conventional tradingsystem, blockchain will have the following properties:
- Decentralized: Blockchain operates independently under computeralgorithms, completely free from any organization That's why blockchainavoids third-party risks
- Distributed: Blocks contain the same data but are dispersed in differentplaces So unfortunately, if a place is lost or damaged, the data is still on theblockchain
- Unchangable: Once the data has been written into the block of theblockchain, it cannot be altered or repaired, by the characteristics of theconsensus algorithm and hash code
- Security: Only private key holders can access the data inside the blockchain.- Transparency: Transactions in the blockchain are saved and people can check
these transactions Based on that, we can check and retrieve the transactionhistory One can even decentralize to allow others to access some of theinformation on the Blockchain
- Smart contract integration: Based on which the terms written in the smartcontract will be executed when the previous conditions are satisfied, no onecan prevent or cancel it
19
Trang 21The structure of a blockchain
Blockchain as its name implies is Block and Chain.- Its structure consists of many blocks.- These blocks are linked together, the latter blocks bind to the previous block
that forms the chain
20
Trang 22How Blockchain Technology Works
First, your transaction information will be recorded on the system to create arecord
Image 9 How Blockchain Technology works
Then, your records are validated as valid by the computers in the system (callednodes or nodes) according to the consensus algorithm on the Blockchain
Eg:- The record shows the brother selling 3 Bitcoins The system confirms that⇒
the brother has 3 bitcoins in his wallet Then the record is valid.⇒- If you only have 1 Bitcoin The system determines that your wallet does⇒
not have enough Bitcoins to make the transaction Then the record is⇒invalid
21
Trang 23Next, your valuable authenticated record, along with a series of verified recordsfrom other traders, will be grouped into a block.
Image 11 How Blockchain Technology works 3
Finally, the newly created block (Block) will be added to the chain (Chain) byconnecting the Previous Hash of the block to be added with the hash of the previousblock and forming a Blockchain
The first block since there is no block before it, its Hash is string zero And it iscalled the primordial block or Genesis Block
22
Trang 24Structure of each Block (Block)
Each block consists of 3 components: Data (Data), Hash Code (Hash) and Hashcode of the previous block
- Data: Your verified data records are protected by an encryption algorithmdepending on the blockchain
- Hash: Hash of Block This is a sequence of characters and numbers that arerandomly generated and are not identical It specifically represents that blockand is encrypted using a cryptographic algorithm The hash is used to detectchanges in blocks
- Previous Hash: The hash of the previous block It is used to let adjacentblocks know which block is first, which block is next, and connect to eachother
Blockchain Algorithm
Blockchain consensus algorithm is the agreement to verify that the informationin the record is correct by the majority of nodes in the network and allows transactioninformation to be recorded in the Blockchain
If there is a change of a block in the network This data is compared with thedata of other blocks If there is a difference, it will not allow that data to be writteninside the Blockchain That's how Blockchain is designed to resist data change
Example: The case if there is a change on 1 block Here, I assume a hackerattacks and changes information on block A At that time:
- The hash of block A is changed
23
Trang 25- The system will compare that hash with the previous block hash and detectthe difference.
- Thus, the hacker has to change the hash of the block before A The systemagain detects the error in block A-1 The hacker must keep changing the hashof block A-2
- So to change the transaction, the hacker has to change all the blocks becauseof the consensus mechanism
Image 13 Blockchain Algorithm
Blockchain applications in agriculture
Currently, the issue of origin and quality is at the forefront of the agriculturalsector The application of Blockchain in agriculture with a distributed ledger systemwill help retailers and consumers store transaction information, the flow of productsfrom the place of production to retailers and consumers end use
Besides, the data during production and sales is also stored and updatedcontinuously in Blockchain such as quality management, financial management, pricemanagement, etc This helps to increase transparency transparency of products andcreate consumer trust
Applications of Blockchain in Health
Healthcare is a sensitive field for numbers, which fluctuate over a closelyexamined time period
When applying Blockchain in healthcare, all authorized parties can access thesame exact and verified information in seconds
Patients have control of their data at all times and can grant access to others onrequest, reducing the risk of abuse and theft
24
Trang 26Blockchain Application in Banking & Payment
The security and smart contract of Blockchain will help bypass the 3rdintermediaries and limit the security risks for customers
People can access and transfer coins to each other anywhere in the world andwith relatively fast speeds and low costs This helps people in countries that do nothave access to the banking system to transact and transfer money to each other
Image 15 Blockchain in Banking
25
Trang 27In addition, Blockchain is also applied in many other fields such as: IoT - Internetof Things, Decentralized Storage, Charity, Entertainment,
Image 16 Metamask
Users can store and manage their Bitcoin, Ether, and other cryptocurrencies usinga blockchain wallet, which is available as a digital or online wallet A blockchainwallet enables cryptocurrency transfers, prevents theft of crypto assets, and allowsusers to convert them back into their local currencies if needed
MetaMask is the most popular blockchain wallet today, with monthly active userssurpassing 30 million, thus making MetaMask the most widely-used non-custodialcrypto wallet in the world The MetaMask browser extension provides a vital utilityfor crypto gamers, developers, and newcomers to the blockchain space
26
Trang 281.1.7 Visual Studio Code
Visual Studio Code (famously known as VS Code) is a free open source texteditor by Microsoft VS Code is available for Windows, Linux, and macOS Althoughthe editor is relatively lightweight, it includes some powerful features that have madeVS Code one of the most popular development environment tools in recent times
Image 17 Visual Studio Code
Features
VS Code supports a wide array of programming languages from Java, C++, andPython to CSS, Go, and Dockerfile Moreover, VS Code allows you to add on and
27
Trang 29even creating new extensions including code linters, debuggers, and cloud and webdevelopment support.
The VS Code user interface allows for a lot of interaction compared to other texteditors To simplify user experience, VS Code is divided into five main regions:
- The activity bar- The side bar- Editor groups- The panel- The status bar