Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'accounts' of undefined #13

Open
i-likekapil opened this issue May 29, 2021 · 2 comments
Open

Cannot read property 'accounts' of undefined #13

i-likekapil opened this issue May 29, 2021 · 2 comments

Comments

@i-likekapil
Copy link

//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
Copy link

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
Copy link

kamalkech commented Dec 25, 2021

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants