Giter Site home page Giter Site logo

studentcoinhack's Introduction

StudentCoinHack

A student loan network on the ethereum blockchain

Truffle

Update:

npm uninstall -g truffle

npm install -g truffle

how to install

  1. git clone github.com/ericchenmelt/StudentCoinhack

  2. cd StudentCoinhack

  3. npm install -g truffle

  4. npm install -g yarn

  5. yarn install

how to build

  1. Run the development console.

    truffle develop
  2. Compile and migrate the smart contracts. Note inside the development console we don't preface commands with truffle.

    compile
    migrate
    deploy

how to run

  1. yarn start

go to localhost:3000

route ideas:

/ => landing

/student/profile
/student/signup
/student/wallet
/student/myfunders
/student/transactions

/funder/signup
/funder/home

how to not die:

truffle develop

> compile 
> migrate --reset 
> Accounts.deployed().then(function(instance){return instance.incrementStudent("hello world");}).then(console.log);
> Accounts.deployed().then(function(instance){return instance.getStudentCount();}).then(console.log);

how to test deposit and withdrawal

Make sure account1 and account2 have sufficient funds in MetaMask.

truffle compile

truffle migrate --reset

var accounts;

web3.eth.getAccounts(function(err,res) { accounts = res; });

var account1 = accounts[0]; // first account

var account2 = accounts[1]; // second account, if exists

var account3 = accounts[2];

console.log(account1);

Accounts.deployed().then(function(instance){return instance.addStudent("Martin Shrekli", "Columbia", "Phrma bro", "https://ei.marketwatch.com/Multimedia/2016/06/06/Photos/MG/MW-EO507_shkrel_20160606174055_MG.jpg?uuid=59565cec-2c2f-11e6-9347-0015c588dfa6", {from: account3});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.addLender("Raphael", {from: account1});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.addLender("Talal", {from: account2});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.startFundraising(2000, {from: account3});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.getLenderBalanceIdx(0, {from: account1});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.getLenderBalanceIdx(1, {from: account2});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.getStudentRaisedIdx(0, {from: account3});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.fund(0, {from: account1, value: 1000, gas:900000});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.fund(0, {from: account2, value: 1000, gas:900000});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.getNumStudentFundersIdx(0);}).then(console.log);

Accounts.deployed().then(function(instance){return instance.getStudentRaisedIdx(0, {from: account2});}).then(console.log);

Accounts.deployed().then(function(instance){return instance.getContractBalance()}).then(console.log);

Accounts.deployed().then(function(instance){return instance.withdraw(250, {from: account3});}).then(console.log);

//Amount left in student's contract after withdrawl
Accounts.deployed().then(function(instance){return instance.getStudentRaisedIdx(0, {from: account2});}).then(console.log);

//Amount in student's bank account after withdrawl
web3.fromWei(web3.eth.getBalance(account3));

Accounts.deployed().then(function(instance){return instance.addStudent("Martin Shrekli", "Columbia", "Phrma bro", "https://ei.marketwatch.com/Multimedia/2016/06/06/Photos/MG/MW-EO507_shkrel_20160606174055_MG.jpg?uuid=59565cec-2c2f-11e6-9347-0015c588dfa6");}).then(console.log);

Accounts.deployed().then(function(instance){return instance.getStudentPhotoURL(0);}).then(console.log);

function getStudentPhotoURL(uint idx) public view returns(string) { return slist[idx].photourl; }

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.