Git Product home page Git Product logo

7ccsmdlc's Introduction

ResAloc

A simple decentralized resource allocation system, with truffle-suite and vue.js.

Guide

Step 1: Install MetaMask

MetaMask is a browser extension that support both Chrome, Firefox, and other modern browsers. It is an Ethereum wallet system that provides functionalities for managing Ethereum accounts and handling transactions. This Dapp require MetaMask to make interact with Ethereum blockchain, so please first install MetaMask in your browser.

Step 2: Install Ganache

Ganache, part of Truffle suite, provides a personal blockchain environment for Ethereum development. For dev and test purpose, we use Ganache as the Ethereum network where our smart contracts will be deployed to. Just install Ganache and use the "quickstart" workspace, and then switch MetaMask network to the local Ganache network.

quickstart

Step 3: Build and setup

Go to our Github repo, download project code and install dependencies.

# download project code
git clone https://github.com/qige96/7CCSMDLC.git

# install dependencies
npm install

Setup initial accounts (only these accounts are allowed to make transactions).

setup-account

copy and past these addresses to settings.js

setup-account2

Deploy contracts and build front-end interface.

# deploy smart contracts
npx truffle migrate

# build front-end app at 127.0.0.1:8080
npm run dev

Now you can see whether you can play with the system. More docs, please refer to docs or wiki.

7ccsmdlc's People

Contributors

qige96 avatar zzgdqh avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

ethancloud666

7ccsmdlc's Issues

本周产品原型图

本周希望的产出就是下面着这钟效果
image


开始动工

前端组直接把GitHub上的truffle项目克隆下来,再项目中写代码,然后push到GitHub上。可能很多工作需要和我一起做,建议你们今明两天线做一些尝试和探索,找个周末时间段碰面一起写代码。

合约组把 https://cryptozombies.io/en/course/ 这个课程学习一下,下周我们要考虑权限控制以及第一阶段的实现,需要一些高级的solidity编程手段。


有任何好的想法或者提议都可以再下面回复或者再微信里跟我说

项目预启动

各位,我已经把项目的proposal发给老师了,具体内容可以在这里查看

这是我关于这个项目的大致设想

我们要做一个去中心化的资源分配系统。

整个系统在以太坊上开发,因为以太坊封装好了所有区块链需要的底层技术(数字签名、工作量证明、挖矿打包等),我们只需要专注于应用的逻辑。

系统的结构分两部分,一个是区块链后端,包含资源分配的核心逻辑;另一个是用户界面,提供简单的用户操作。用户界面可以是客户端也可以是网页,最好全都要,实在不行就优先网页端。

资源分配的核心流程:

  1. 初始分配。用户在deadline前提交资源请求,deadline后系统随机分配资源(这一点技术上可以实现,但目前方案不太经济,正在探索新方案,或者最后会把这一阶段去掉)。
  2. 后续交易(最重要)。用户在初始分配后可以释放不再需要的资源,然后其余用户可以抢夺这些资源。以后可以加入更多功能,比如定向交换,悬赏之类的。

然后是第一阶段的目标

2月9号前我们要有一个最小可行产品,后续时间都在这个最小可行产品上加功能和做调优。

总体要求

  1. 实现最基本的系统初始化
  2. 实现资源释放和资源申请功能
  3. 有一个用户界面
  4. 把系统部署到测试网上,且能使用用户界面做资源申请和释放操作。

技术选型

目前我打算使用Truffle来编写代码。这是一个JS库,帮助我们把写好的智能合约部署到区块链上,并提供与之交互的机制。

API

后端的智能合约API

contract SimpleResourceAllocation {
    // 构造函数,接收一个整数数组,每一个数组元素代表相应编号的资源的数量,前端应该用不上
    constructor (uint[] memory initQuotes) public ;
    // 争抢资源,成功会返回true
    function request(uint res_id) public returns (bool success);
    // 释放资源,成功会放回true
    function release(uint res_id) public returns (bool success);
    // 查看所有资源的可用余额,返回一个整数数组
    function viewAllQuotes() public view returns (uint[] memory allQuotes);
    // 查看自己持有的资源,返回一个布尔数组,像应位置为true代表拥有该编号的资源
    function viewMyResources() public view returns (bool[] memory myResources);
    
}

另外关于分工的话,我抓破脑袋也只想到这种分法:

  • 一个负责像合约代码
  • 一个负责给合约做维护(测试、code review)
  • 一个负责写前端代码
  • 一个负责给前端做维护(测试、code review)
  • 最后一个负责指手画脚

热烈欢迎所有意见和建议!

项目正式启动

今晚项目开始正式启动啦!可喜可贺,可喜可贺!

分工情况

  • Yi Li 负责前端页面编写。
  • Shijia WU 负责前端代码的测试和CR
  • Yunxiang Cai 负责智能合约代码的测试,CR,辅助编写逻辑
  • Ruiqi Zhu 负责智能合约代码编写,同时指手画脚
  • Ziwei Yang 负责智能合约代码的测试,CR,辅助编写逻辑

第一阶段各组任务

  • 前端组:熟悉Truffle的使用方法。建议从官方文档简介以及教程入手。周四下午与合约组商定进一步的事宜。
  • 合约组:掌握solidity的基本语法和智能合约的基本结构。建议把官方exampleremix编辑器上过一遍。周四下午与前端组商定进一步的事宜。

第一阶段的系统目标

  1. 初始化一个有三种资源的系统,其初始额度分别为 [3, 6, 9]。
  2. 一个用户可以在网页上查看目前所有资源的可用余额。
  3. 用户点击刷新按钮可以查看最新的资源的可用余额。
  4. 一个用户可以在网页上点击按钮申请一个资源,然后浏览器弹出提示告知用户成功与否。
  5. 一个用户可以在网页上点击按钮释放一个资源,然后浏览器弹出提示告知用户成功与否。

欢迎大家提出各种idea!

Design issues

  1. 第一阶段(初始分配)可以实现,但目前方案不甚经济,可以考虑删掉。
  2. 目前每人的资源额度没有上限,考虑限制没人只能拥有n个资源(e.g. 每人最多只能选6门课)。
  3. 考虑加入交易机制,比如悬赏交换。
// 向所有参与者广播,请求用res_reward 交换 res_wanted
function want(res_wanted, res_reward) public returns (uint trade_id);
// 同意进行trade_id的交易(愿意用自己的资源交换)
function deal(trade_id) public returns (bool success);
// 撤回交易
function withdrawTrade(trade_id) public return (bool success);
  1. 考虑加入代币机制,作为资源的id(如果唯一)或者交易通货。

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.