Blockchain Decentralized Application – 区块链分散应用区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Blockchain Decentralized Application – 区块链分散应用区块链毕设代写 是一篇很好的国外资料

Blockchain Decentralized Application

The following project is a small decentralized application that basically showcases the use of blockchain as a secondary data base alongside an offchain database with MongoDB. The application consists in a login using smart contracts, which means using truffle contracts in the backend.

The usage of blockchain as a secondary database is the following: every time a user sings in in the login, after knowing the user is valid according to MongoDB registry, the hash of the login input is compared to blockchain’s registry and only if this is validated, the user is able to access safely.

Specifications

NodeJS version: 10.15.3
express version: 4.17.1
express-handlebars version: 3.1.0
express-session version: 1.16.2
mongodb version: 2.2.33
truffle-contract version: 4.0.31
web3 version: 1.2.1
ganache-cli version: 6.7.0

The folder node_modules was uploaded to this repo because if you try to install web3 using npm, you might encounter some bug in certain web3 packages and it might not work. That is why I suggest to download this full folder from here as well.

Usage

After downloading this repo to your local directory, the next thing to do is to download Ganache Quickstart for desktop version. Once installed, turn on your Ganache environment (click on Quickstart).

Turn on MongoDB service. Search for services inside your computer. Right click on MongoDB Server and choose Start.

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

Go to Windows Powershell, and enter to the project’s folder. Once there, type: truffle console --network ganache to enter Truffle Console. Then, type migrate --compile-all --reset to compile the Smart contracts (do this everytime you change a contract). This also delets any registry in the blockchain. Finally, type .exit to exit the console.

Now, start the server. Type npm start on your Powershell. This is equivalent to typing node ./bin/www. On this file, you will see the port for the project is 3000.

You will see first the login page. On the bottom, the MongoDB registry of users will be displayed. In this case, the users will start in zero, like below.

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

Whenever you reset all contracts, you should click on Restart DB to empty the MongoDB registry just as the Ganache one. They should have the same amount of users.

If you click on Register, you will be able to type the username and password of a new user, like below. Keep in mind that only the super user can add a new user, and this is validated by the blockchain using the account hash of whoever is calling the new user transaction.

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

When you confirm the new user, you get redirected to the login page, where you will be able to see the new user’s info down below. All this is just for proof of concept.

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

If you sign in as the new user, you will enter the main page, given the validation using the blockchain hash registry.

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

Here, you can choose to see the Transaction Information by clicking on Audit button. This will take you to the following page, which shows the corresponding user registration information that was stored when the blockchain added the user.

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

This info should coincide with the Ganache Quickstart info. If you click on the transaction by recognizing the hash, you will see the info:

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

You can also click on the Register button and add another user again. Users displayed on the bottom parts are updated using Ajax calls every 3 seconds.

Finally, you can access the Blockchain Market where you will be able to sell and buy items. Access looks like the following:

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

To stop the server, go to Powershell and type Ctrl + C.

Smart Contracts in Solidity

The language for smart contracts in this dapp is Solidity. To add a smart contract, first create a file using .sol extension in the contracts folder. Write your code in Solidity and then, go to the file migrations/2_deploy_contracts.js and use the function deployer.deploy() as with the other contracts.

The file routes/index.js is where most of the backend’s smart contract use is done.

Blockchain Market

The Market section uses Metamask for the account notifications.


区块链blockchain分散应用程序规范

使用

稳定智能合约

区块链blockchain市场

下面的项目是一个小型的去中心化应用程序,它基本上展示了将区块链blockchain与MongoDB的链外数据库一起用作辅助数据库。应用程序包括使用智能合约的登录,这意味着在后端使用truffle合约。

区块链blockchain作为二级数据库的用法是:每次用户登录时,在根据MongoDB registry知道用户有效后,将登录输入的哈希值与区块链blockchain的注册表进行比较,只有验证后,用户才能安全访问。

使用

NodeJS版本:10.15.3
express版本:4.17.1
express handlebars版本:3.1.0
express session版本:1.16.2
mongodb版本:2.2.33
truffle contract版本:4.0.31
web3版本:1.2.1
ganache cli版本:6.7.0

文件夹节点u模块已上载到此repo,因为如果您尝试使用npm安装web3,您可能会在某些web3包中遇到一些bug,并且可能无法正常工作。这就是为什么我建议也从这里下载这个完整的文件夹。

稳定智能合约

将这个repo下载到您的本地目录后,下一步要做的是下载Ganache Quickstart for desktop版本。安装后,打开Ganache环境(单击Quickstart)。

打开MongoDB服务。在计算机中搜索服务。右键单击MongoDB服务器并选择“开始”。

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

转到Windows Powershell,然后进入项目文件夹。到达之后,输入:truffle console–network ganache进入truffle console。然后,键入migrate–compile all–reset编译智能合约(每次更改合约时都这样做)。这也会删除区块链blockchain中的任何注册表。最后,键入.exit退出控制台。

现在,启动服务器。在Powershell上键入npm start。这个节点相当于www.bin/port,你可以看到这个文件。

您将首先看到登录页面。在底部,将显示用户的MongoDB注册表。在这种情况下,用户将从零开始,如下所示。

每当您重置所有契约时,您应该单击Restart DB以清空MongoDB注册表,就像清空Ganache注册表一样。他们应该有相同数量的用户。

如果单击Register,您将能够键入新用户的用户名和密码,如下所示。请记住,只有超级用户才能添加新用户,这由区块链blockchain使用调用新用户事务的用户的帐户哈希进行验证。

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

当您确认新用户时,您将被重定向到登录页面,您将能够在下面看到新用户的信息。所有这些只是为了概念证明。

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

如果您以新用户身份登录,您将进入主页面,使用区块链blockchain哈希注册表进行验证。

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

在这里,您可以选择通过单击审核按钮查看交易信息。这将带您进入下一页,其中显示了区块链blockchain添加用户时存储的相应用户注册信息。

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

此信息应与Ganache快速启动信息一致。如果您通过识别哈希来单击事务,您将看到以下信息:

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

您还可以单击“注册”按钮并再次添加另一个用户。底部显示的用户每3秒使用Ajax调用更新一次。

最后,您可以访问区块链blockchain市场,在那里您可以销售和购买物品。访问如下所示:

Blockchain Decentralized Application - <a href=区块链blockchain分散应用”>

若要停止服务器,请转到Powershell并键入Ctrl+C。

此dapp中的智能合约语言为Solidity。要添加智能合约,请首先使用contracts文件夹中的.sol扩展名创建一个文件。用Solidity编写代码,然后转到文件migrations/2u deploy_合同.js并使用函数部署器.deploy()与其他合同一样。

区块链blockchain市场

文件路由/索引.js是后端使用智能合约的大部分地方。

市场部分使用元掩码作为帐户通知。

Blockchain Market

The Market section uses Metamask for the account notifications.

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

www.interchains.cc

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

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

提供最优质的资源集合

立即查看 了解详情