48733/web3-accounts-coming-undefined
Hi Sir, Is it the correct way to access web 3 accounts (trying many ways ) but accounts coming undefined
web3.eth.getAccounts(function(error, accounts) { if (error) { console.error(error); } console.log(web3.eth.getAccounts); // get first (base) account // var account = accounts[0]; ==============================
please suggest correct latest way that should work
Hi @gaurav!
To access all the accounts, you can use this code:
web3.eth.getAccounts().then(e => console.log(e));
And to get the first account, you can use this:
web3.eth.getAccounts().then(e => let firstAcc=e[0]; console.log(firstAcc));
The chain ID for ropsten is 3. ...READ MORE
All you need to do is enter ...READ MORE
As the error suggests, pub/sub is not ...READ MORE
The setLog transaction has not yet been mined by ...READ MORE
This was a bug. They've fixed it. ...READ MORE
Summary: Both should provide similar reliability of ...READ MORE
recipes is a dynamic storage array. You need ...READ MORE
I solved problem, using: web3.eth.getAccounts((err, res) => ...READ MORE
Try compiling and migrating the contract: $ truffle ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.