Skip to content

wildanvin/classroomDao

Repository files navigation

classroomDao

Live Demo

Live demo in vercel

Project description

I was inspired by this article.

TL;DR of the article:

'It is well stablished that higher literacy rates correlate to higher “gross domestic product,” then incentivizing people to continue their schooling could boost productivity, individual well-being, and societal prosperity. World governments would reward people with so-called "country coins" for continued learning. A student earns coins by completing online courses and passing tests. The coins would essentially represent claims on a “trust fund” set up by the state; they would entitle recipients to future payouts representing a share of the rising tax revenue generated by increased GDP.'

I really like this idea and I believe education is a key aspect for long term social prosperity and well being. But I don't think world governments (especially the developing ones) are going to implement this in the near future. So, this project is a MVP of this idea.

There are two smart contracts in this project, ClassroomFactory.sol and Classroom.sol. Through the front end, the teacher (or anyone who wants to create a classroom and share their knowledge) will interact with the ClassroomFactory.sol and create an instance of Classroom.sol, this new created Classroom instance is a multisig wallet that I modified slightly from the example found in solidity-by-example.org (that guy is awesome)

Every Classroom will be like a mini DAO, with a max of 21 participants (including the teacher) and will need the approval of 15 participants in order to execute a transaction.

Rigth now, an approved transaction will just distribute the funds evenly to the participants. For example, if I create a classroom with a duration of 4 weeks (or 4 sessions), and the participants manage to get 1 ETH for this classroom, the first approved transaction will send 0,0119 ETH (0.25 ETH / 21 participants) to each participant. Why 0.25 ETH? Because for each transaction, the bounty is divided by the number of sessions that the classroom has. So, the first transaction executed will distribute 0.25 ETH among the participants, the second transaction will distribute again 0.25 ETH, the third 0.25 ETH and finally the fourth transaction the remaining 0.25 ETH.

It would be awesome to use Coordinape to build the transaction and distribute the funds according to participation or other positive actions (help fellow students, complete homeworks, etc), but that will be for later.

Deployed version URL

You can interact with de dApp in this link. Please take into account that in this demo each classroom has a max of 3 participants and needs the approval of 2 to execute transactions. Of course you can change that in the contract Classroom.sol at lines 21 & 22 and redeploy

Deployed Address

The ClassroomFactory.sol contract is deployed in the Goerli network at 0x27DD46923B826153f1D0fd54B99cFC8211Df6E02 & Classroom.sol at 0x1A39aDf0A0c615f114Ce35b6A7E8D1139Bd94853

Screencast Link

You can find a demo video in youtube

How to run the project locally

Prerequisites:

  • npm >= 6.13.4
  • node >= 12.16.1
  • truffle
  • ganache

Steps:

  1. Clone the repository in empty directory.

  2. Open a new terminal and run ganache-cli you can use the GUI version of ganache too. Make sure ganache is accessible on port 8545. It should say something like Listening on 127.0.0.1:8545

  3. Now, let's go back to the terminal where you cloned the project and run: truffle migrate --network development

  4. Notice that the FE code is in the client folder. So, open a new terminal and run cd client. Now that we are in the client folder run npm install.

  5. We need to change the value of the INPROD variable from true to false in the following files. Go to:

    • client/src/components/ClassroomList.jsx line 12.
    • client/src/pages/Classroom.jsx line 41.
    • client/src/pages/CreateClass.jsx line 50.

    Why do you need to do that to make it work locally?

    • When the INPROD variable is set to false it uses the JSON-server package to create a mock API in the db.json file wich is perfect for testing locally. If the INPROD variable is set to true it uses a serverless function in vercel that stores the data in a mongo database, wich is more suited for a production environment.
  6. Now run npm run dev to spin up the react front end and the mock database.

  7. You now should be able to interact with the contracts through the front-end in your browser at localhost:3000

  8. Now that you are on the front end don't forget to change the network in Metamask to Localhost:8545 and add an account using the mock private keys that ganache provides.

Directory Structure

This project was bootstrapped with a react truffle box, so the project directory is kind of standard

  • client: Contains a react app.
  • contracts: Smart contracts.
  • migrations: Migration files for deploying contracts in contracts directory.
  • test: Tests for smart contracts. Right now no test is implemented

Environment variables (not needed for running project locally)

If you want to deploy the contracts to the Goerli testnet, create a .env file in the same directory as the truffle-config.js with the following variables (complete them with your infura project ID and your mnemonic):

INFURA_API_KEY=
MNEMONIC=

and run in the terminal truffle migrate --network goerli

Contact

If you have any issues, suggestions, feedback or ideas feel free to reach out on twitter

About

Dapp to foster continuous education

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published