crowdfund-dapp

所属分类:以太坊
开发工具:JavaScript
文件大小:3095KB
下载次数:0
上传日期:2017-06-06 11:27:52
上 传 者sh-1993
说明:  去中心化众筹应用
(Decentralized crowdfund app)

文件列表:
build_webpack (0, 2017-06-06)
build_webpack\asset-manifest.json (196, 2017-06-06)
build_webpack\create_project.png (99355, 2017-06-06)
build_webpack\favicon.ico (32038, 2017-06-06)
build_webpack\funding_hub_screen.png (95523, 2017-06-06)
build_webpack\index.html (481, 2017-06-06)
build_webpack\project.png (112306, 2017-06-06)
build_webpack\static (0, 2017-06-06)
build_webpack\static\css (0, 2017-06-06)
build_webpack\static\css\main.1dc8af22.css (209, 2017-06-06)
build_webpack\static\css\main.1dc8af22.css.map (105, 2017-06-06)
build_webpack\static\js (0, 2017-06-06)
build_webpack\static\js\main.07303cb5.js (1190660, 2017-06-06)
build_webpack\static\js\main.07303cb5.js.map (9750043, 2017-06-06)
config (0, 2017-06-06)
config\env.js (1102, 2017-06-06)
config\jest (0, 2017-06-06)
config\jest\cssTransform.js (323, 2017-06-06)
config\jest\fileTransform.js (301, 2017-06-06)
config\paths.js (1888, 2017-06-06)
config\polyfills.js (613, 2017-06-06)
config\webpack.config.dev.js (9665, 2017-06-06)
config\webpack.config.prod.js (10068, 2017-06-06)
contracts (0, 2017-06-06)
contracts\ConvertLib.sol (167, 2017-06-06)
contracts\FundingHub.sol (2603, 2017-06-06)
contracts\Migrations.sol (492, 2017-06-06)
contracts\Project.sol (7898, 2017-06-06)
docker-compose.yml (311, 2017-06-06)
migrations (0, 2017-06-06)
migrations\1_initial_migration.js (129, 2017-06-06)
migrations\2_deploy_contracts.js (129, 2017-06-06)
nginx.conf (1829, 2017-06-06)
package.json (2894, 2017-06-06)
public (0, 2017-06-06)
public\create_project.png (99355, 2017-06-06)
public\favicon.ico (32038, 2017-06-06)
... ...

## Decentralized Crowdfunding App This is a simple crowdfunding dapp intended to show off what I've learned from the B9 Lab Ethereum course. The contracts are written in Solidity and the app is utilizing the Truffle framework. The frontend of the app is built with React and Webpack. [https://github.com/tyndallm/crowdfund-dapp](https://github.com/tyndallm/crowdfund-dapp) ### Contracts **FundingHub.sol** The first contract is the Funding Hub. This contract is responsible for creating and maintaining a list of all Project contracts. FundingHub also offers a contribute method which can be used to contribute directly to a Project. To demonstrate a potential business model use-case Projects have been locked to only allow receiving of funds from their managing Funding Hub. You can imagine a scenario in which the FundingHub takes a small fee for managing each project. **Project.sol** This contract contains all of the logic around how a crowdfunding project should operate. Projects are "locked" to their Funding Hub and can only receive funds sent thru the associated FundingHub contract address. There are three main functions: (fund, payout, and refund) *Fund* This is the function called when the FundingHub receives a contribution. If the contribution was sent after the deadline of the project passed, or the full amount has been reached, the function must return the value to the originator of the transaction. If the full funding amount has been reached, the function must call payout. **NOTE**: This is slightly different than the original instructions. I wanted to enforce the withdrawal pattern in the refund method as opposed to a group send. The withdrawal pattern is generally considered safer and avoids some of the pitfalls of call depth and out-of-gas issues, [see more here](https://solidity.readthedocs.io/en/develop/common-patterns.html#withdrawal-from-contracts). *Payout* If funding goal has been met, transfer fund to project creator. This function protects against re-entrancy and is only payable to the project creator. *Refund* If the deadline is passed and the goal was not reached, allow contributors to withdraw their contributions. **NOTE** This is slightly different that the final project requirements, see above for details. ### App The frontend app for this project is built on React and forks off of the [truffle-webpack-demo project](https://github.com/ConsenSys/truffle-webpack-demo) by Consensys. The cool thing about this is that it combines the latest in regular frontend javscript development with Ethereum. In order to manage the state of the dapp, Redux was chosen. One of my goals of this project was to see if there was a way I could abstract the asynchronous web3 and contract calls into a simple API that I could then integrate into a standard React+Redux Action/Reducer flow. This was achieved with the web3Api.js file. This approach works well with the asynchronous nature of interacting with the blockchain as things like contract properties, and account balances can seemlessly notify the app when they have updated and the UI will reflect those changes instantly. Here is an example of how this flow works: 0. Upon initial load the app dispatchs ```fetchProjectsAndDetails()``` 0. fetchProjectsAndDetails dispatchs the ```requestProjects``` Action and makes async request to web3Api's ```getProjects()``` function 0. When the ```getProjects()``` request resolves it returns the result to the ```fetchProjectAndDetails()``` function and dispatchs the ```receivedProjects``` Action which notifies the FundingHub Reducer that the state has changed. 0. When the app sees that the state for FundingHub has changed, the UI re-renders with the new project properties and the projects are displayed in a table on the page ### Screenshots ![Funding Hub screen](https://github.com/tyndallm/crowdfund-dapp/raw/master/public/funding_hub_screen.png) ![Create project screen](https://github.com/tyndallm/crowdfund-dapp/raw/master/public/create_project.png) ![Project screen](https://github.com/tyndallm/crowdfund-dapp/raw/master/public/project.png) ### Running The Web3 RPC location will be picked up from the `truffle.js` file. 0. Clone this repo 0. `npm install` 0. Make sure `testrpc` is running on its default port. Then: - `npm run start` - Starts the development server - `npm run build` - Generates a build - `truffle test` - Run the rest suite

近期下载者

相关文件


收藏者