dappuniversity / eth-todo-list

Blockchain Todo App Tutorial Powered by Ethereum Smart Contracts
549 stars 549 forks source link

Cannot read property 'accounts' of undefined #13

Open i-likekapil opened 3 years ago

i-likekapil commented 3 years ago

//app.js loadAccount: async ()=>{ App.account = web3.eth.accounts[0] // line no. 42 console.log(App.account) }

//console app.js:42 Uncaught (in promise) TypeError: Cannot read property 'accounts' of undefined at Object.loadAccount (app.js:42) at Object.load (app.js:9)

shwetha-pingala commented 3 years ago

These are the old methods to call the web3 library. If you have installed a new truffle version other than 5.0.2 it won't run.

kamalkech commented 2 years ago

@shwetha-pingala that s reason it s better to add new branch for last updates on diffirents tools like metamask @i-likekapil use this line and u will get solution

const accounts = await ethereum.request({ method: 'eth_accounts' });

for more details check this link https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3