基于区块链的毕业设计Emeralds supplychain Dapp – 绿宝石供应链

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计Emeralds supplychain Dapp – 绿宝石供应链 是一篇很好的国外资料

Emeralds supplychain Dapp - 绿宝石供应链 Emeralds supplychain Dapp - 绿宝石供应链 Emeralds supplychain Dapp - 绿宝石供应链 Emeralds supplychain Dapp - 绿宝石供应链

Emeralds supplychain Dapp

Smart contracts project with solidity for manage emeralds supply chain.

In this project, We explore an Ethereum Dapp development for a decentralized emeralds supply chain. The main goal is reduce intermediaries from the miner to the final client. The project is developed incrementally following agile methodologies. We are going to update documents and code with each version.

Emeralds supply chain process

Colombia is the biggest emeralds producer worldwide; close to 60% of all emeralds production comes from there. Colombian emeralds are recognized for their quality and beautiful tones. The extraction process still handcrafts in many areas and has an extensive traders and intermediaries network. The next diagrams show a general view of actors, and steps involved in the emeralds production and trading:

Emeralds supplychain Dapp - 绿宝石供应链

The challenge is to apply blockchain to create a Decentralized App that helps trade emeralds in a trustworthy market supported by Smart Contracts on the Ethereum platform. We start by simplifying the supply chain problem and breaking the trading cycle into two parts. The first one starts with the extraction and ends with the trading process of cut emeralds, and the second one starts with the cut emeralds and finishes when jewels with emeralds are sell to the final customer.

Part1:

Emeralds supplychain Dapp - 绿宝石供应链

Part2

Emeralds supplychain Dapp - 绿宝石供应链

Part 1 description

We are focusing on process part 1 for the first Dapp version. In this version, the main goal is to reduce the intermediaries and offer a trustworthy supply chain where miners and clients (final clients or jewel producers) can trade easily with less risk. For this first Dapp version, we consider these actors:

  • Miners: Companies or people extracting emeralds from the mines.
  • Laboratories: Specialized laboratories that certify the quality grade and other emeralds properties
  • Custodians: Companies offering secure store for certified emeralds
  • Manufacturers: Companies offering cutting and polishing services transforming raw emeralds into shaped stones
  • Jewelers: Companies or people manufacturing jewels

Part 2 description

Dapp’s part 2 cover the process from de cut emerald to jewel creation and selling to final clients. In this part, we look for a way to directly connect the jewel makers with final clients in a trustworthy trading system. This part considers for example the transformation of a cut emerald to a luxury jewel that can use other materials (For example gold or other gems). The actors involved in this second part are:

  • Material supplier: Companies that provide other materials required for jewels manufacturing
  • Jewels certifier: Companies certifying the quality grade and jewels final properties
  • Final client: Final buyers of manufactured jewels

Technical challenges

  • Contracts cost deployment: We need to keep small contracts size and operations
  • Low storage capacity and cost: The Ethereum networks are costly to save information, we need to Keep in the blockchain the minimum data
  • Transactions cost: We need to minimize the transactions calls and data transfer on the network
  • Secutiry: Managed users control and authorization for different actors involved and keep the accounts safe.

Functional requirements

The process starts with the emerald extraction performed by the miner in the mine. The miner needs to scale the stone with information like weight, color, size, and clarity grade. These are technical parameters to a detailed description of each emerald. After scale, the emerald needs to be packeted to ship to the specialized laboratory authorized by the miner for trusted technical verifications and properties certification. Once emerald is shipped to Laboratory, this one needs to confirm the reception and do the certification process. The certified emerald is sent to a secure custodian storage service, authorized by the miner in the packaging process. The Custodian storage confirms reception, store the emerald and send a verification to the miner, who at this point, have a certified and secured emerald and can register for sale, setting up the price based on the certified properties. With the emeralds in the raw emerald in the market, the manufacturer can buy a raw emerald to cut and polish them to make a product able to be used in jewel manufacturing. The manufacturer buys the emerald, taking its ownership, and ships an order to the custodian to get the raw emerald to their processing factory. The Manufacturer process the emerald, pack for sale and register for a market sale with the new prices market. The jewel creators can search all the stones in the cut emeralds offer and buy them. When they transfer the amount to the manufacturer, they send the cut emerald to the customer location and confirm the final reception.

Product roapmap:

Emeralds supplychain Dapp - 绿宝石供应链

Blockchain architecture design:

To accomplish this task, we are going to use UML (Universal Modeling Language) to design architectural views of our system. The architectural views to use are:

  • Activities model: Describe the actor’s interactions and the flow of activities.
  • Sequence model: To help us to understand the actors and objects’ message interchange.
  • States diagram: Used to let us understand emerald’s state in each activity in the flow.
  • Class model: Express the data and functions needed in each contract.

Activy diagram

Emeralds supplychain Dapp - 绿宝石供应链

Sequence diagram

Emeralds supplychain Dapp - 绿宝石供应链

States diagram

Emeralds supplychain Dapp - 绿宝石供应链

Class diagram

Emeralds supplychain Dapp - 绿宝石供应链

Contracts implementation

To understand project class organization and contract implementation we need to consider the external libraries and folders. This is presented in the next diagram:

Emeralds supplychain Dapp - 绿宝石供应链

Project write-up – Libraries

We use openzeppely library to implements accesscontrol and ownable contracts for an easy role and authorization management. The development uses Truffle framework, web3 to interact with the contract and truffle-hd-wallet-provider to sign transactions for addresses.

  • Oppenzeppelin: (https://docs.openzeppelin.com/openzeppelin/)
  • Truffle: (https://www.trufflesuite.com/)
  • web3: (https://web3js.readthedocs.io/en/v1.3.0/)

IPFS

IPFS is not used in this Dapp version.

IPFS: (https://ipfs.io/)

Contracts deployment on Kovan test network

To deply the contratcs on Rinkeby network, is neccessaty setup the truffle-config.js file with this:

``` kovan: {   // must be a thunk, otherwise truffle commands may hang in CI   provider: () =>     new HDWalletProvider({       mnemonic: {         phrase: mnemonicPhrase       },       providerOrUrl: infuraKovan,       gas: 5500000,           confirmations: 2,       timeoutBlocks: 200,       skipDryRun: true,        shareNonce: true     }),   network_id: '42', } ``` 

The adress for the supplychaon contract on the rinkeby network is:

Contract address on the (Etherscan):

https://rinkeby.etherscan.io/address/0x1d4396d3dfdfffb57e2ae580f175e7dfcf08759a

Transaction ID and contract address

======================

Network name: ‘rinkeby’ Network id: 4 Block gas limit: 0x989677

1_initial_migration.js

Deploying ‘Migrations’

transaction hash: 0x1a02bb12fc80417e2ad1bd56250775110126d74e48fbb03041ae98b24ff92052 Blocks: 1 Seconds: 21 contract address: 0x302cfAe2e65F6651f3fDB5fAe6f635ca62CA567b block number: 5625069 block timestamp: 1576515319 account: 0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A balance: 0.97167573 gas used: 238594 gas price: 10 gwei value sent: 0 ETH total cost: 0.00238594 ETH

Saving migration to chain. Saving artifacts


Total cost: 0.00238594 ETH

2_deploy_contracts.js

Deploying ‘FarmerRole’

transaction hash: 0x79b84bba9672baeb0181fa97016e03510903903052a19f4a4a6f0168627ef9ca Blocks: 1 Seconds: 12 contract address: 0xa041c902B5E6a8a83c9A3cf6D55C65183eb2462f block number: 5625071 block timestamp: 1576515349 account: 0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A balance: 0.96674205 gas used: 451020 gas price: 10 gwei value sent: 0 ETH total cost: 0.0045102 ETH

Deploying ‘DistributorRole’

transaction hash: 0xf245353475ad170ce060d54680cb2003f8abf9ecdef52db245791b3ca9f79b41 Blocks: 0 Seconds: 9 contract address: 0xaf1624F9BA8972070eE42311684BE921000355b1 block number: 5625072 block timestamp: 1576515364 account: 0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A balance: 0.96223113 gas used: 451092 gas price: 10 gwei value sent: 0 ETH total cost: 0.00451092 ETH

Deploying ‘RetailerRole’

transaction hash: 0xec3342fef968e5791df950cf6e1ba8b037d348b11f26e8f5a58f2cb41e6523fe Blocks: 0 Seconds: 9 contract address: 0xaf4Cb7bb1ED23FA76f18E34261BE81584Bc6c792 block number: 5625073 block timestamp: 1576515379 account: 0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A balance: 0.95772033 gas used: 451080 gas price: 10 gwei value sent: 0 ETH total cost: 0.0045108 ETH

Deploying ‘ConsumerRole’

transaction hash: 0x0346a0f1176aacbc2f70d695d25d3ff0bc2b2c5b7b29257e530a3c63510a595a Blocks: 0 Seconds: 7 contract address: 0x59Fb032D660d3830Ec24729D6A57286c8Cef0dd8 block number: 5625074 block timestamp: 1576515394 account: 0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A balance: 0.95320977 gas used: 451056 gas price: 10 gwei value sent: 0 ETH total cost: 0.00451056 ETH

Deploying ‘SupplyChain’

transaction hash: 0x33d25ff003526fa072304b4fcb2921d8e160c37b3cd70292d6a842cf6cecbb49 Blocks: 1 Seconds: 10 contract address: 0x66c0486577009EC26A9429B1E38657Ba0fa5c2B0 block number: 5625075 block timestamp: 1576515409 account: 0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A balance: 0.92025103 gas used: 3295874 gas price: 10 gwei value sent: 0 ETH total cost: 0.03295874 ETH

Saving migration to chain. Saving artifacts


Total cost: 0.05100122 ETH

Summary

Total deployments: 6 Final cost: 0.05338716 ETH

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Please make sure you’ve already installed ganache-cli, Truffle and enabled MetaMask extension in your browser.

Give examples (to be clarified) 

Installing

A step by step series of examples that tell you have to get a development env running

Clone this repository:

git clone https://github.com/udacity/nd1309/tree/master/course-5/project-6 

Change directory to project-6 folder and install all requisite npm packages (as listed in package.json):

cd project-6 npm install 

Launch Ganache:

ganache-cli -m "spirit supply whale amount human item harsh scare congress discover talent hamster" 

Your terminal should look something like this:

Emeralds supplychain Dapp - 绿宝石供应链

In a separate terminal window, Compile smart contracts:

truffle compile 

Your terminal should look something like this:

Emeralds supplychain Dapp - 绿宝石供应链

This will create the smart contract artifacts in folder buildcontracts.

Migrate smart contracts to the locally running blockchain, ganache-cli:

truffle migrate 

Your terminal should look something like this:

Emeralds supplychain Dapp - 绿宝石供应链

Test smart contracts:

truffle test 

All 10 tests should pass.

Emeralds supplychain Dapp - 绿宝石供应链

In a separate terminal window, launch the DApp:

npm run dev 

Built With

  • Ethereum – Ethereum is a decentralized platform that runs smart contracts
  • IPFS – IPFS is the Distributed Web | A peer-to-peer hypermedia protocol to make the web faster, safer, and more open.
  • Truffle Framework – Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier.

Authors

See also the list of contributors who participated in this project.

Acknowledgments

  • Solidity
  • Ganache-cli
  • Truffle
  • IPFS

具有管理翡翠供应链的稳固性的智能合约项目。

翡翠供应链Dapp

在本项目中,我们探索以太坊ethDapp开发,以实现分散式翡翠供应链。主要目标是减少从矿工到最终客户的中间人。这个项目是按照敏捷的方法逐步开发的。我们将用每个版本更新文档和代码。

哥伦比亚是全球最大的祖母绿生产国;将近60%的祖母绿生产来自哥伦比亚。哥伦比亚祖母绿因其质量和美丽的色调而被公认。提取过程在许多领域仍然是手工艺品,并拥有广泛的贸易商和中间商网络。接下来的图表展示了绿宝石生产和交易的参与者和步骤的一般视图:

翡翠供应链流程

Emeralds supplychain Dapp - 绿宝石供应链

挑战在于应用区块链blockchain创建一个分散的应用程序,帮助在以太坊eth平台上的智能合约支持的可信市场中交易绿宝石。我们从简化供应链问题开始,把交易周期分成两部分。第一种方法从提取开始,到切割翡翠的交易过程结束;第二种方法从切割翡翠开始,到翡翠珠宝出售给最终客户为止。

Emeralds supplychain Dapp - 绿宝石供应链

第1部分:

Emeralds supplychain Dapp - 绿宝石供应链

第2部分描述

我们关注第一个Dapp版本的过程第1部分。在这个版本中,主要的目标是减少中间人,并提供一个值得信赖的供应链,矿工和客户(最终客户或珠宝生产商)可以以较低的风险轻松交易。对于Dapp的第一个版本,我们考虑这些参与者:

第2部分描述

Dapp的第2部分涵盖了从去切割祖母绿到珠宝创作以及销售给最终客户的过程。在这一部分中,我们寻找一种方法,在一个值得信赖的交易系统中,将珠宝制造商与最终客户直接联系起来。例如,这一部分考虑将切割的祖母绿转变为可以使用其他材料(例如黄金或其他宝石)的豪华珠宝。第二部分涉及的参与者是:

  • Miners: Companies or people extracting emeralds from the mines.
  • Laboratories: Specialized laboratories that certify the quality grade and other emeralds properties
  • Custodians: Companies offering secure store for certified emeralds
  • Manufacturers: Companies offering cutting and polishing services transforming raw emeralds into shaped stones
  • Jewelers: Companies or people manufacturing jewels

技术挑战

这个过程从矿主在矿井中提取翡翠开始。矿工需要用重量、颜色、大小和净度等信息来衡量石头。这些都是对每种翡翠的技术参数进行详细的描述。定级后,需要将翡翠打包运往矿主授权的专业实验室进行可靠的技术验证和性能认证。一旦翡翠被运到实验室,这一个需要确认接收和做认证过程。经认证的祖母绿被送到一个安全保管存储服务,由矿工在包装过程中授权。保管仓库确认收到祖母绿,储存祖母绿,并向矿工发送验证,此时,矿工拥有经过认证和担保的祖母绿,可以注册出售,并根据认证的财产设定价格。由于市场上的原祖母绿中的祖母绿,制造商可以购买原祖母绿进行切割和抛光,制成可用于珠宝制造的产品。制造商购买祖母绿,取得所有权,并将订单交给保管人,以便将原祖母绿运到他们的加工厂。制造商加工翡翠,包装出售,并登记市场销售与新的价格市场。珠宝创造者可以搜索切割翡翠提供的所有宝石并购买它们。当他们将数量转移给制造商时,他们会将切割好的祖母绿送到客户处,并确认最终的接收结果。为了完成这项任务,我们将使用UML(通用建模语言)来设计系统的体系结构视图。要使用的架构视图是:

  • Material supplier: Companies that provide other materials required for jewels manufacturing
  • Jewels certifier: Companies certifying the quality grade and jewels final properties
  • Final client: Final buyers of manufactured jewels

功能要求

  • Contracts cost deployment: We need to keep small contracts size and operations
  • Low storage capacity and cost: The Ethereum networks are costly to save information, we need to Keep in the blockchain the minimum data
  • Transactions cost: We need to minimize the transactions calls and data transfer on the network
  • Secutiry: Managed users control and authorization for different actors involved and keep the accounts safe.

产品roapmap:

Emeralds supplychain Dapp - 绿宝石供应链

区块链blockchain架构设计:

要理解项目类组织和合同实现,我们需要考虑外部库和文件夹。这将在下一个图中显示:

活动图

Emeralds supplychain Dapp - 绿宝石供应链

  • Activities model: Describe the actor’s interactions and the flow of activities.
  • Sequence model: To help us to understand the actors and objects’ message interchange.
  • States diagram: Used to let us understand emerald’s state in each activity in the flow.
  • Class model: Express the data and functions needed in each contract.

序列图

我们使用openzeppely库来实现访问控制和可拥有的契约,以方便角色和授权管理。开发使用了Truffle框架,web3与合同进行交互,Truffle hd wallet供应商为地址签署交易。

状态图

此Dapp版本中不使用IPFS。

类图

IPFS:(https://ipfs.io/)

合同执行

要在林克比网络上发布合同,有必要把松露装起来吗-配置.js文件如下:

项目编写-库

rinkeby网络上supplychaon合同的地址是:

https://rinkeby.etherscan.io/address/0x1d4396d3dfffb57e2ae580f175e7dfcf08759a

IPFS

===================

  • Oppenzeppelin: (https://docs.openzeppelin.com/openzeppelin/)
  • Truffle: (https://www.trufflesuite.com/)
  • web3: (https://web3js.readthedocs.io/en/v1.3.0/)

合同部署在Kovan测试网络上

网络名称:“rinkeby”网络id:4块气体限制:0x989677

事务哈希:0x1a02bb12fc80417e2ad1bd56250775110126d74e48fbb03041ae98b24ff92052块:1秒:21合约地址:0x302cfAe2e65F6651f3fDB5fAe6f635ca62CA567b块号:5625069块时间戳:1576515319帐户:0x1D4396D3DFFFB57E2AE580F175E7DFCF08759A余额:0.97167573使用:238594天然气价格:10 gwei发送值:0 ETH总成本:0.00238594 ETH。保存工件

合同地址(Etherscan):

总成本:0.00238594 ETH

``` kovan: {   // must be a thunk, otherwise truffle commands may hang in CI   provider: () =>     new HDWalletProvider({       mnemonic: {         phrase: mnemonicPhrase       },       providerOrUrl: infuraKovan,       gas: 5500000,           confirmations: 2,       timeoutBlocks: 200,       skipDryRun: true,        shareNonce: true     }),   network_id: '42', } ``` 

事务哈希:0x79b84bba9672baeb0181fa97016e0310903903052a19f4a6f0168627ef9ca块:1秒:12合约地址:0xa041c902B5E6a8a83c9A3cf6D55C65183eb2462f块号:5625071块时间戳:1576515349帐户:0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A余额:0.96674205气体使用量:451020气体价格:10 gwei发送值:0 ETH总成本:0.0045102 ETH

事务ID和合同

事务哈希:0xf245353475ad170ce060d54680cb2003f8abf9ecdef52db245791b3ca9f79b41块:0秒:9合同地址:0xaf1624F9BA8972070eE42311684BE921000355b1区块编号:5625072区块时间戳:1576515364帐户:0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A余额:0.96223113气体使用量:451092气体价格:10 gwei发送值:0 ETH总成本:0.00451092 ETH

Transaction ID and contract address

事务哈希:0xec3342fef968e5791df950cf6e1ba8b037d348b11f26e8f5a58f2cb41e6523fe块:0秒:9合同地址:0xaf4Cb7bb1ED23FA76f18E34261BE81584Bc6c792块编号:5625073块时间戳:1576515379帐户:0x1d4396d3dfffb57e2ae580f175e7dfcf08759a余额:0.95772033用气:451080天然气价格:10 gwei发送值:0 ETH总成本:0.0045108 ETH事务哈希:0x0346A0F1176AACBC2F70D695D25D3FF0BC2B2C5B7B29257E530A3C63510A5955A块:0秒:7合同地址:0x59Fb032D660d3830Ec24729D6A57286c8Cef0dd8块号:5625074块时间戳:1576515394账户:0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A余额:0.95320977用气:451056气价:10gwei发送值:0eth总成本:0.00451056eth

事务哈希:0x33d25ff003526fa072304b4fcb2921d8e160c37b3cd70292d6a842cf6cecbb49块:1秒:10合同地址:0x66c048657709ec26a9429b1e38657ba0fa5c2b0区块编号:5625075区块时间戳:1576515409账户:0x1D4396D3DfdFFFB57e2Ae580f175E7DFCf08759A余额:0.92025103用气:3295874天然气价格:10gwei发送值:0 ETH总成本:0.03295874 ETH

1_initial_migration.js

Deploying ‘Migrations’

保存到链的迁移。保存工件

总成本:0.05100122 ETH


总部署:6最终成本:0.05338716 ETH

2_deploy_contracts.js

Deploying ‘FarmerRole’

这些说明将为您提供项目的副本,并在本地计算机上运行,以用于开发和测试。有关如何在活动系统上部署项目的说明,请参见部署。

Deploying ‘DistributorRole’

请确保您已经在浏览器中安装了ganache cli、Truffle和启用的MetaMask扩展。

Deploying ‘RetailerRole’

一系列分步示例告诉您必须运行开发环境

Deploying ‘ConsumerRole’

克隆此存储库:

Deploying ‘SupplyChain’

将目录更改为project-6文件夹并安装所有必需的npm包(如中所列)包.json):

启动Ganache:


您的终端应该是这样的:

Summary

Emeralds supplychain Dapp - 绿宝石供应链

Getting Started

在一个单独的终端窗口中,编译智能合约:

Prerequisites

您的终端应该如下所示:

Give examples (to be clarified) 

Installing

这将在文件夹buildcontracts中创建智能合约工件。

将智能合约迁移到本地运行的区块链blockchain,ganache cli:

git clone https://github.com/udacity/nd1309/tree/master/course-5/project-6 

您的终端应该是这样的:

cd project-6 npm install 

Emeralds supplychain Dapp - 绿宝石供应链

ganache-cli -m "spirit supply whale amount human item harsh scare congress discover talent hamster" 

测试智能合约:

所有10个测试都应该通过。

Emeralds supplychain Dapp - 绿宝石供应链

truffle compile 

在一个单独的终端窗口中,启动DApp:

另请参阅参与此项目的贡献者列表。

This will create the smart contract artifacts in folder buildcontracts.

Migrate smart contracts to the locally running blockchain, ganache-cli:

truffle migrate 

Your terminal should look something like this:

Emeralds supplychain Dapp - 绿宝石供应链

Test smart contracts:

truffle test 

All 10 tests should pass.

Emeralds supplychain Dapp - 绿宝石供应链

In a separate terminal window, launch the DApp:

npm run dev 

Built With

  • Ethereum – Ethereum is a decentralized platform that runs smart contracts
  • IPFS – IPFS is the Distributed Web | A peer-to-peer hypermedia protocol to make the web faster, safer, and more open.
  • Truffle Framework – Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier.

Authors

See also the list of contributors who participated in this project.

Acknowledgments

  • Solidity
  • Ganache-cli
  • Truffle
  • IPFS

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/20469.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计Emeralds supplychain Dapp – 绿宝石供应链

提供最优质的资源集合

立即查看 了解详情