Giter VIP home page Giter VIP logo

my_simple_voting_dapp's Introduction

Usage

  1. npm install
  2. use ./node_modules/.bin/ganache-cli start a ganache test chain
  3. use ./node_modules/.bin/solcjs --abi --bin Voting.sol to get the abi and code bin file
  4. in the node-cli
    1. var Web3 = require('web3')
    2. var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
    3. use web3.isConnected() test whether the web3 connected the ganache chain or not
    4. copy the content of the abi and the bin
    5. var abi ={the content of the abi}
    6. var bytecode={the content of the bin}
    7. var VotingContract = web3.eth.contract(abi)
    8. contractInst = VotingContract.new(["Alice","Bob","Cary"],{data:bytecode,from:web3.eth.accounts[0],gas:5000000}) after this you can see a json data about the contract in the cli
    9. get the address of the contract contractInst.address

Anyway,my abi is like this:

[{"constant":true,"inputs":[{"name":"candidateName","type":"bytes32"}],"name":"totalVotesFor","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"votesReceived","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"candidateName","type":"bytes32"}],"name":"vote","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"candidateList","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"candidateListName","type":"bytes32[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]

bin:

608060405234801561001057600080fd5b506040516103c53803806103c5833981018060405281019080805182019291905050508060009080519060200190610049929190610050565b50506100c8565b828054828255906000526020600020908101928215610092579160200282015b82811115610091578251829060001916905591602001919060010190610070565b5b50905061009f91906100a3565b5090565b6100c591905b808211156100c15760008160009055506001016100a9565b5090565b90565b6102ee806100d76000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632f265cf7146100675780637021939f146100b2578063a69beaba146100fd578063b13c744b1461012e575b600080fd5b34801561007357600080fd5b506100966004803603810190808035600019169060200190929190505050610177565b604051808260ff1660ff16815260200191505060405180910390f35b3480156100be57600080fd5b506100e160048036038101908080356000191690602001909291905050506101bd565b604051808260ff1660ff16815260200191505060405180910390f35b34801561010957600080fd5b5061012c60048036038101908080356000191690602001909291905050506101dd565b005b34801561013a57600080fd5b506101596004803603810190808035906020019092919050505061023a565b60405180826000191660001916815260200191505060405180910390f35b60006101828261025d565b151561018d57600080fd5b60016000836000191660001916815260200190815260200160002060009054906101000a900460ff169050919050565b60016020528060005260406000206000915054906101000a900460ff1681565b6101e68161025d565b15156101f157600080fd5b6001806000836000191660001916815260200190815260200160002060008282829054906101000a900460ff160192506101000a81548160ff021916908360ff16021790555050565b60008181548110151561024957fe5b906000526020600020016000915090505481565b600080600090505b6000805490508160ff1610156102b75760008160ff1681548110151561028757fe5b906000526020600020015460001916836000191614156102aa57600191506102bc565b8080600101915050610265565b600091505b509190505600a165627a7a723058207a1e42461e716a028925ddade6f5985292c8fa9657086ffeff465dc0f669bd460029

my_simple_voting_dapp's People

Contributors

krisjiaqixie avatar

Stargazers

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