dappuniversity / election

A Decentralized Ethereum Voting Application Tutorial
563 stars 506 forks source link

Unable To Vote: Accounts Undefined #25

Open officialfrancismendoza opened 5 years ago

officialfrancismendoza commented 5 years ago

I am unable to call app.vote(1, from: web3.eth.accounts[0]}), but not because I have insufficient Ether (premise of an issue raised by someone else)

My program, for some reason, treated all the accounts array values as undefined..

Attached below is a screenshot detailing how I have a list of addresses, but none of those are stored within web3.eth.accounts, and I am unsure why image

Attempted to fix this issue by manually setting an address equal to a memory location within the accounts array in Git bash. However, it gives an error message of an unrecognized account when calling app.vote image image

In both instances, I have null accounts and accounts that are not recognized. I have been stuck for nearly 2 hours. Where is the problem localized? Within what file are these accounts instantiated to begin with? (assume no new files)

faruk13 commented 5 years ago

Using getAccounts you should get a list of accounts, then on the app instance pass the first address(or any one) to another variable.

web3.eth.getAccounts().then( function(s){FirstAccount=s[0]; return FirstAccount})

then use,

app.vote(1,{from:FirstAccount})