Giter Club home page Giter Club logo

eth_grade_manager's Introduction

Eth_Grade_Manager

This is the example from A Beginner’s Guide to Blockchain Programming written by Febin John James.

Getting started

1.Install dependencies. ganache-cliweb3.jssolc

$ npm install
$ node_modules/.bin/ganache-cli

2.Compile solidity code.

$ node
$ code = fs.readFileSync('Grades.sol').toString()
$ solc = require('solc')
$ compiledCode = solc.compile(code)

3.Deploy the code on ethererum praivate newtwork by using web3.js.

$ Web3 = require('web3')
$ web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
$ abiDefinition = JSON.parse(compiledCode.contracts[':Grades'].interface)
$ GradesContract = web3.eth.contract(abiDefinition)
$ byteCode = compiledCode.contracts[':Grades'].bytecode
$ deployedContract = GradesContract.new(['John','James'],{data: byteCode, from: web3.eth.accounts[0], gas: 4700000})

How to use

Give Grade A+ to John by follwing code.

$ deployedContract.giveGradeToStudent('John', 'A+', {from: web3.eth.accounts[0]})    

Call john's grade.

$ deployedContract.getGradeForStudent.call('John')
'A+'

eth_grade_manager's People

Contributors

naogify 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.