- Node.js >= v16
- Ganache UI
- Metamask extension installed and, to run local tests, a new Localhost network configured on RPC
http://localhost:7545
(The default one is on port 8545) - Clone this repo! :)
- Run
npm install
in project´s root directory. This will install Truffle, hdwallet, dotenv and OpenZeppelin ReentrancyGuard among others dependencies - Run Ganache UI in port
7545
and network id1337
Remember to add the truffle-config.js in Ganache´s truffle project. You can change the Network ID clicking in the configuration gear, then going to server and setting the Network ID to 1337 there - To test the contract, edit
./contracts/PapaPay.sol
, uncomment lines 293 to 310 (fetchCourse function), save changes, and from project´s root directory run runtruffle migrate --network development --reset
and then runtruffle test
- To deploy the contract locally, edit
./contracts/PapaPay.sol
and after re-commenting lines 293 to 310, runtruffle migrate --network development --reset
- Go to client directory
cd client
- If you want to use the previous locally deployed contract edit
./src/index.js
and change line 22, state variablemyChain
from0x3
(That´s Ropsten chainId) to0x539
(Ganache´s 1337 chainId). Save and exit. - Run
npm install
to install packages and dependencies - To start the server run
npm run start
- Open
http://localhost:3000
https://www.loom.com/share/6b82735180be439b9df677f52f145d8b
0x2fB6E185Dd70265D86298CAF775851262048e74C
This aims to solve the exchange of value when a tutor and a student engage in a one-on-one lesson, specially when both resides in different countries.
- Both parts meet to arrange an economic value and other requirements for the course wich is composed by one or more lessons.
- When they agree, the tutor creates a course and names it, declares the price of the entire course, the lessons quantity, a timelock wich allows the student to recover it´s assets after a period of time if the tutor doesn´t give the promised class, and, of course, the student address.
- The student then reviews that, and if agrees, approves the course, deducting the course value from the student´s wallet and storing it in the contract.
- When the student attends to a lesson, it signs a attendance counter, that allows the tutor to give the lesson (signing a init lesson counter) and therefore allowing the tutor to withdraw a fraction of the balance stored in the contract corresponding to the given lessons
- If a tutor doesn´t start a lesson after a student gives it´s attendance, or, the student never attend any lesson, the student can recover the balance left in the contract after the timelock period specified in the course creation
- Enter PapaPay website
- Select
I´m a tutor
- Clic on
Create Course
- Follow the on-screen instructions and fill all the fields (Use a student address under your control to test it later)
- Clic on
Create Course
- See tx status under Create Course button
- Enter PapaPay website
- Select
I´m a student
(Remember to use the student address declared earlier) - Read the on-screen sugestions, look out for your course and clic on
Approve Course
. You need to have sufficient ETH balance in your wallet for this to work - Then, attend your first lesson by clicking on
Take Lesson
- Always see tx status on bottom of the page
- Enter PapaPay website
- Select tutor, then select
Give a Lesson
- Look out for your course and clic on
Give Lesson
. - After a successful transaction, you can clic on
Withdraw
, if tx is successful, check your new balance in your wallet, and the new balance on the course - Always see tx status on bottom of the page
- Enter PapaPay website
- Select student (Remember to use the student address declared earlier)
- Read the on-screen sugestions, look out for your course and clic on Recover Balance
- If the timestamp hasn´t passed, metamask will throw a revert. After the timelock, there will be a successful transaction, you can check your new balance in your wallet, and the new balance on the course
- Always see tx status on bottom of the page
client
: React frontend.contracts
: Smart contracts.migrations
: Migration files for deploying contracts.test
: Unit tests.
ROPSTEN_INFURA_PROJECT_ID=
ROPSTEN_MNEMONIC=
- Stop using block.timestamp and use Chainlink Keepers
- Improve gas consumption
- Improve React code, implement a place where students and tutors can pre-arrange a course