dappuniversity / election

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

not displayed the list of candidates after all installations #21

Open antonyhudson opened 5 years ago

antonyhudson commented 5 years ago

What may be the problem, restarting the browser does not help?

malavancs commented 5 years ago

I'm also facing the same issue

antonyhudson commented 5 years ago

And how did you fix it?

malavancs commented 5 years ago

The problem is account returned from metamask was null. To avoid this issue, Add this line after ethereum.enable(); when creating web3 object.

PlanCZero commented 5 years ago

Hi @malavancs Can you explain more about this? ethereum.enable(); Some other browser has reported Uncaught ReferenceError: ethereum is not defined but it work on chrome.

TheNewMrRobot commented 5 years ago

where ..

The problem is account returned from metamask was null. To avoid this issue, Add this line after ethereum.enable(); when creating web3 object.

where to add etherreum.enable()

malavancs commented 5 years ago

@Vignesh1010

On index.js

initWeb3: function() { // TODO: refactor conditional if (typeof web3 !== 'undefined') { // If a web3 instance is already provided by Meta Mask. App.web3Provider = web3.currentProvider;

etherreum.enable(); web3 = new Web3(web3.currentProvider); } else { // Specify default instance if no web3 instance provided App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545'); etherreum.enable(); web3 = new Web3(App.web3Provider); }

jkariscodes commented 5 years ago

etherreum.enable();

This has worked in my case. Thanks @vignesh1010 image

officialfrancismendoza commented 5 years ago

I am not able to see candidates, despite using ethereum.enable(). What are other possible causes for this? initWeb3: function() { // TODO: refactor conditional if (typeof web3 !== 'undefined') { // If a web3 instance is already provided by Meta Mask. App.web3Provider = web3.currentProvider; ethereum.enable(); web3 = new Web3(web3.currentProvider); } else { // Specify default instance if no web3 instance provided App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545'); ethereum.enable(); web3 = new Web3(App.web3Provider); } return App.initContract(); }, image

malavancs commented 5 years ago

etherreum.enable();

This has worked in my case. Thanks @vignesh1010 image

Btw It was me to thank :(

dyttokaa commented 5 years ago
Screenshot 2019-06-24 at 01 43 19

That's all i can see... cant define the problem... help please

malavancs commented 5 years ago

Check for console logs. Make sure you've added

initWeb3: function() {
// TODO: refactor conditional
if (typeof web3 !== 'undefined') {
// If a web3 instance is already provided by Meta Mask.
App.web3Provider = web3.currentProvider;

etherreum.enable();
web3 = new Web3(web3.currentProvider);
} else {
// Specify default instance if no web3 instance provided
App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545');
etherreum.enable();
web3 = new Web3(App.web3Provider);
}
bongi23 commented 5 years ago

I had a similar issue, caused by web3.eth.getCoinbase returning null account, I solved following these steps:

MhamedBendenia commented 4 years ago

For those who etherreum.enable(); doesn't work, try window.ethereum.enable(); it worked for me.