Code Monkey home page Code Monkey logo

ethereum_shop_dapp's Introduction

一个基于Ethereum & IPFS的去中心化交易平台和资讯平台

1 总览

       本平台拥有虚拟商品发布、购买、评价、排序,资讯发布、资讯评论、资讯排序功能。基于Ethereum & IPFS实现真正的去中心化。

1.1 商品

  • 以太币兑换购物币

index.png
testIndex.gif

  • 发布商品

deployProduct.png
deployProduct.gif

  • 购买商品(其他账号,购买商品前需要兑换代币)

productHome.png
testPurchseProduct.gif

  • 评价商品

testCommentProduct.gif

  • 查看本账号发布的商品和已经购买的商品(关键字检索,类型检索)

myProducts-type.png

myProducts-search.png

testMyProduct.gif

  • 商品排序(销量榜,评分榜,价格榜,综合榜)

productSort.png

testProductSort.gif

1.2 资讯

  • 发布资讯

deployNews.png

testDeployNews.gif

  • 评价资讯(作者评价,多次评价)

testNewsComment.gif

  • 资讯主页(关键字检索,类型检索)

newsHome.png

testNewsHome.gif

  • 我的资讯(发布的资讯和已经评价过的资讯,关键字检索,类型检索)

myNews.png

myNews1.png

  • 资讯排序(评分和时间榜)

testNewsSort.gif

2 运行前准备

2.1 安装IPFS

  • 下载ipfs压缩包

$ wget https://dist.ipfs.io/go-ipfs/v0.4.13/go-ipfs_v0.4.13_linux-amd64.tar.gz

  • 解压

tar -zxvf go-ipfs_v0.4.13_linux-amd64.tar.gz

  • 移动文件

$cd go-ipfs
$ sudo mv ipfs /usr/local/bin/ipfs

  • 在本地计算机建立一个IPFS节点

ipfs init

  • 跨域资源共享CORS配置

$ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST", "OPTIONS"]'
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '[""]'


windows配置跨域资源共享CORS
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST", "OPTIONS"]'


ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["
"]'

  • 启动ipfs服务

$ ipfs deamon

  • 浏览器访问IPFS节点

http://localhost:5001/webui

2.2 安装truffle框架

  • sudo apt-get install nodejs
  • sudo apt-get install npm
  • sudo npm install -g truffle
  • 安装指定版本的truffle——sudo npm install -g truffle@"指定版本"

例子:sudo  npm install -g [email protected]

2.3 安装ganache测试框架

2.4 安装以太坊浏览器插件metamask

  • 下载安装插件downloadMetamask.png

  • metamask关联truffle框架

打开metamask——>设置——>显示助记词——>复制助记词

metamask-ci.png

打开ganache——>设置——>ACCOUNTS&KEYS
ganache-ci.png

ganache.png

3 项目目录

  • build

智能合约编译后生成的json文件

  • contracts

智能合约

  • migrations

智能合约部署脚本

  • src(项目应用层和中间层)
  • test

智能合约测试脚本

4 项目运行

  • 启动IPFS

ipfs deamon

  • 启动ganache

./ganache
windows就直接双击ganahce.exe即可。

  • 编译

truffle compile

  • 部署

truffle migrate

  • 安装项目依赖(第一次运行项目)

npm install

  • 运行

npm run dev
会自动打开浏览器通过localhost:3000访问

5 参考资料

ethereum_shop_dapp's People

Contributors

wongnoubo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ethereum_shop_dapp's Issues

运行出问题

当我运行项目,买入游戏币点击兑换时,提示invalid address,我个人怀疑是index.js代码中的web3.eth.accounts[0]不能使用(在web3新版本中),但不知道怎么修改,在此请教一下博主,这个问题该怎么解决呢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.