Giter Club home page Giter Club logo

ethereum_voting_dapp's People

Contributors

djrtwo avatar juneyoung-kang avatar maheshmurthy avatar smokincaterpillar avatar zastrin 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  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  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  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

ethereum_voting_dapp's Issues

Votes count doesn't revert when the vote transaction is removed

Description

Transactions on blockchain can be removed due to chain reorganization.
When the vote transaction is executed in a block, the DApp update the vote count in the UI.
However, if the chain reorganization happens and the transaction got removed from history, but the vote count is not reverted.

Reproduce Steps

One reproduce example is given below.

  1. submit a vote by sending a transaction
  2. mine a block and execute the transaction
  3. at this time, the DApp has updated the vote count
  4. chain reorganization happens, where the previous transaction is removed from history
  5. the vote count is not reverted as transaction does.

Expected Behaviour

The transaction removed by chain reorganization should reflected to the UI, and the vote count should also be reverted.

Why not use address.transfer?

function transferTo(address account) {
    if (!account.call.value(this.balance)()) throw;
}

This function appears on line 125 in Voting.sol in chapter 3. I'm wondering why the function isn't simply: account.transfer(this.balance);?

showing error for npm run dev

PS C:\Users\Acer\newelection\ethereum_voting_dapp-master\chapter2\node_modules\webpack-dev-server> npm run webpack-dev-server

[email protected] webpack-dev-server C:\Users\Acer\newelection\ethereum_voting_dapp-master\chapter2\node_modules\webpack-dev-server
node examples/run-example.js

internal/modules/cjs/loader.js:983
throw err;
^

Error: Cannot find module 'C:\Users\Acer\newelection\ethereum_voting_dapp-master\chapter2\node_modules\webpack-dev-server\examples\run-example.js'
er.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] webpack-dev-server: node examples/run-example.js
npm ERR! Exit status 1
PS C:\Users\Acer\newelection\ethereum_voting_dapp-master\chapter2\node_modules\webpack-dev-server> npm run webpack-dev-server

[email protected] webpack-dev-server C:\Users\Acer\newelection\ethereum_voting_dapp-master\chapter2\node_modules\webpack-dev-server
node examples/run-example.js

internal/modules/cjs/loader.js:983
throw err;
^

Error: Cannot find module 'C:\Users\Acer\newelection\ethereum_voting_dapp-master\chapter2\node_modules\webpack-dev-server\examples\run-example.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] webpack-dev-server: node examples/run-example.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] webpack-dev-server script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Acer\AppData\Roaming\npm-cache_logs\2020-04-25T21_56_53_268Z-debug.log

i am not able to run npm run dev getting the above error

Cannot read property '0' of undefined

I run the following command:

  1. truffle console
  2. hash = web3.sha3("message")
  3. web3.personal.sign(hash, web3.eth.account[0])
    When I run the above commands I can not sign. It reported the following error "TypeError: Cannot read property '0' of undefined"
    I'm using your chapter 4

app.js not found in index.html in chapter 4

html file links to app.js with incorrect path. Does it have an incorrect path? Or maybe does it use third library which allows to access to this file without of specifying the path to it like Meteor?

Error: The contract code couldn't be stored, please check your gas amount.

Hello. I was trying to deploy the contract of the chapter3 and the console printed this error:

The contract code couldn't be stored, please check your gas amount.

I compared the file 2_deploy_contracts.js used in chapter3 with used in chapter2 and I noticed that was missing the gas value as shown below:

// the actual chapter3 2_deploy_contracts.js file
var Voting = artifacts.require("./Voting.sol");
module.exports = function(deployer) {
  deployer.deploy(Voting, 1000, web3.toWei('0.1', 'ether'), ['Rama', 'Nick', 'Jose']);
}; 
//what I did
var Voting = artifacts.require("./Voting.sol");
module.exports = function(deployer) {
  deployer.deploy(Voting, 1000, web3.toWei('0.1', 'ether'), ['Rama', 'Nick', 'Jose'],{gas: 6700000});
};

It worked fine when I did it.
I don't know if it is correct or if I did something wrong.

Thanks!

throw is deprecated

Hi, first of all thanks for the great tutorial.

I just came across one minor issue. throw in Voting.sol is deprecated.

Does it make sense to replace it with revert()?

Web3 js not working properly

Promise failed to return

deployedContract.deploy({
... data: bytecode,
... arguments: [listOfCandidates.map(name => web3.utils.asciiToHex(name))]
... }).send({
... from: 'ENTER 1 OF 10 ACCOUNT ADDRESSES like 0xfb3....',
... gas: 1500000,
... gasPrice: web3.utils.toWei('0.00003', 'ether')
... }).then((newContractInstance) => {
... deployedContract.options.address = newContractInstance.options.address
... console.log(newContractInstance.options.address)
... });

**
Uncaught:
Error: Provided address "ENTER 1 OF 10 ACCOUNT ADDRESSES like 0xfb3...." is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can't be converted.
at Object.inputAddressFormatter (F:\ethereum_voting_dapp-master\ethereum_voting_dapp-master\chapter1\node_modules\web3-core-helpers\lib\formatters.js:398:11)
at Contract.getOrSetDefaultOptions [as _getOrSetDefaultOptions] (F:\ethereum_voting_dapp-master\ethereum_voting_dapp-master\chapter1\node_modules\web3-eth-contract\lib\index.js:304:66)
at Object._processExecuteArguments (F:\ethereum_voting_dapp-master\ethereum_voting_dapp-master\chapter1\node_modules\web3-eth-contract\lib\index.js:700:42)
at Object._executeMethod (F:\ethereum_voting_dapp-master\ethereum_voting_dapp-master\chapter1\node_modules\web3-eth-contract\lib\index.js:720:68)**

truffle console throws null accounts error

On running command truffle console or truffle migrate, the following error is thrown everytime even accounts exist.

/usr/local/lib/node_modules/truffle/lib/environment.js:66
        config.networks[config.network].from = accounts[0];
                                                       ^

TypeError: Cannot read property '0' of null
    at /usr/local/lib/node_modules/truffle/lib/environment.js:66:56
    at /usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/property.js:119:13
    at /usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/requestmanager.js:89:9
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:119:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:509:12)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:469:24)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

unable to complile the code

Getting the following output on complining the code with :-
compiledCode = solc.compile(code)

Output:-
'{"errors":[{"component":"general","formattedMessage":"* Line 1, Column 1\\n Syntax error: value, object or array expected.\\n* Line 1, Column 2\\n Extra non-whitespace after JSON value.\\n","message":"* Line 1, Column 1\\n Syntax error: value, object or array expected.\\n* Line 1, Column 2\\n Extra non-whitespace after JSON value.\\n","severity":"error","type":"JSONError"}]}'

when i try to buy token for voting there isn't any token solded

it seems like it keep returning zero

var buyObject = {
value: 25,
from: web3.eth.accounts[0]
};
contractInstance.buy.call(buyObject).then(function(result) {
console.log(">>>> " + result);
web3.eth.getBalance(contractInstance.address, function(error, result) {
console.log(result);
console.log(web3.fromWei(result.toString()));
});
}).catch(function(err) {
console.log("Error creating contract!" + err);
console.log(err.stack);
});

Account 0 : 99.99999999999662
Account 1 : 100
Account 2 : 99.99999999999846

Update pragma

pragma solidity ^0.4.6; //We have to specify what version of the compiler this code will use
Line 1 of Voting.sol should probably read:
pragma solidity ^0.4.10; //We have to specify what version of the compiler this code will use
Given the change to:
account.transfer(this.balance);
on line 126 the contract will no longer compile on solc version <0.4.10.
This gives the error:

Compiling ./contracts/Voting.sol...

/home/vagrant/ethereum_voting_dapp/chapter3/contracts/Voting.sol:126:5: Error: Member "transfer" not found or not visible after argument-dependent lookup in address
account.transfer(this.balance);
^--------------^
Compiliation failed. See above.

On previous solc versions.
I'd do a pull request but I'm having trouble installing the latest Truffle at the moment so can't verify the fix.

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.