GithubHelp home page GithubHelp logo

lucagobbi / sticktogetthere Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 179 KB

An Ethereum Dapp for fundraising written in Django, Solidity and Web3.py

License: GNU General Public License v3.0

Python 29.29% HTML 49.28% Solidity 7.37% CSS 10.55% JavaScript 3.51%

sticktogetthere's Introduction

sticktogetthere

An Ethereum Dapp for fundraising written in Django, Solidity and Web3.py.

What is it?

Stick To Get There is a platform written in Django that implements a smart contract through Web3.py for the back-end and some Web3.js for the front-end. The smart contract is built to implement a fundraising system to collect funds and propose spending requests that can be allowed only by contributors.

The admin is launching the platform setting his/her account as head account, this will be the only account allowed to create new projects, or, in other words, new contracts. All the interactions between users and the platform are happening via blockchain and they can communicate with the platform through front-end UI which exploits Web3.js and Metamask, no data are stored locally in DB.

The admin can create a project describing the cause, setting an amount to raise and a deadline for the campaign. Once the project is created, a new smart contract is deployed on the blockchain and available on the platform. Users can search for this project and contribute for the cause. The admin can also create spending requests which can be completed only if contributors have reached consensus on that, implementing a voting system via blockchain. Once consensus is reached, the admin can effectively spend those funds.

Setting up the environment

Once you have downloaded the source code from Github you should create a virtual environment to launch the website locally.

Be sure you have Python installed in your machine, this project is built with Python 3.9.5.

In your workspace run this command to create a new venv:

python -m venv venv

Be sure to activate your venv to install there all the requirements, on Windows using PowerShell:

path\to\venv\Scripts\Activate.ps1

Once you're working in the venv, install there all the requirements:

pip install -r path/to/requirements.txt

Now, before launching Django, you have to change some parameters in the code to make it work in your environment. Go to fundraising/utils.py and set paramters of web3.py to work with your blockchain provider. If you are working with Ganache be sure to change the following parameters with the ones in your Ganache workspace:

provider = "***RPC_server***"
chain_Id = "***network_id***"

Change the value of my_address and private_key to set your admin account (I picked up the first one in my Ganache workspace), from this account will be sent all the transactions for the creation of a new project:

my_address = "***admin_address***"
private_key = "***admin_private_key***"

Now you should be able to start Django calling these commands:

python manage.py makemigrations
python manage.py migrate --run-syncdb

Create a superuser from CLI, this will be your admin account. Run this command and follow all the steps to create a new user:

python manage.py createsuperuser

Well, it's done. You should now be able to launch the server running:

python manage.py runserver

Using the platform

The UI inside the platform is very user-friendly. If you are logged in as admin you can create a new project: open new project within the dropdown under the username, follow the steps to create a new project and send it. You should now be able to see the project in the projects section. Users can contribute and vote to the requests interacting with the related contract via blockchain.

Testing with Brownie

This project also include a brownie directory built with the Brownie development and testing framework which includes some tests of the Fundraising smart contract. I could write all the interactions using Brownie, simplifying various steps instead of using Web3.py; however, for learning purposes, I decided to develop this project through raw Web3.py.

Returning to tests, once you are in the brownie directory, simply call:

brownie test

If tests are passed the contract is working as expected.

License

GPL-3.0-or-later

Thank you for being patient till here and let me know if I can make any improvements! Have fun!

sticktogetthere's People

Contributors

lucagobbi avatar

Stargazers

Shivam kumar Jha 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.