Git Product home page Git Product logo

dapp-nftauction's Introduction

基于ERC721协议的NFT拍卖行DApp

功能特点

  • 用户可以输入名称并铸造基于ERC721协议的独特NFT装备,每个NFT装备铸造时需要缴纳一笔费用;铸造的每个NFT装备的名称和编号都是独特的(重名会导致铸造失败),并附带一个随机生成的0-100的稀有度(类似某些游戏中的装备磨损度),自己的NFT装备信息和拍卖状态可以在web端的仓库中看到。
  • 用户可以输入编号查看自己拥有的NFT装备的所有权流转信息。
  • 用户可以将自己的NFT装备挂出至拍卖行出售:输入要卖的NFT装备编号,规定好价格和拍卖存续时间并点击sell即可。其他用户也能在拍卖行中浏览在售NFT装备的信息(名称、编号、稀有度、截止时间)。
  • 用户可以输入编号和出价对某个物品进行竞标。超过拍卖时间、出价低于目前最高价、目前编号不存在、支付取消均会造成竞标失败并提示。
  • 拍卖结束后,出价最高者可以手动认领竞标的NFT装备,合约会将它的所有权转到该竞标成功者名下,同时将这一最高竞标费用转至出售者处并计入流转信息。如果没有人竞标,发起拍卖者手动认领出售的装备回自己的仓库,不计入流转信息。
  • 合约创建者可以查看并领取其他用户铸造NFT装备时所花的费用到自己的账户(已在合约中实现,未在App端实现)。
  • 注意:用户在进入拍卖行浏览时需要缴纳一次性的gas费用,在发起和取回拍卖的物品时也需要支付gas费用。

部署方法

在本地部署,确保已经安装ganache或其他本地区块链网络,truffle react框架(依赖于NodeJS)

打开命令行,进入./Project/client目录。

打开remix网页端,命令行输入remixd -s . -u https://remix.ethereum.org/打开本地服务器,与remix相连接(remix中选择Workspaces-localhost)。

在remix中打开contracts目录下的ArmorAuction.sol文件并点击编译,编译完成后,打开ganache并使连接到本地ganache区块链网络,点击部署。

复制remix部署好的合约地址,将Instance.js、StartAuction.js,BiddingItems.js,ListAuction.js四个文件中的合约地址变量address替换为新部署的合约地址。建议用VSCode的搜索替换功能一次性替换掉。

truffle compile对智能合约进行编译并生成字节码文件。

配置truffle-config.js中的网络端口、主机、networkID等信息。

npm start启动项目,默认webApp地址为localhost:3000。打开装有metamask的浏览器访问该网址,部署完毕。

运行成功的网页App截图:

运行成功截图1

运行成功截图2

未来可能的改进

  • 为每个被铸造的不同品级的NFT生成不同颜色的icon,由于目前没有足够的图标资源加上开发时间不够充裕,该功能未实现
  • 支持输入货币/时间值与对应单位
  • 支持自动刷新,但需要考虑合约请求速度问题

dapp-nftauction's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.