18

truffle(development)> web3.eth.accounts[0]

gives output as "undefined"

truffle(development)> web3.eth.accounts

instead of showing all accounts details gives the below output

Accounts {

currentProvider: [Getter/Setter],


_requestManager:

RequestManager {

 provider:

  HttpProvider {
    host: 'http://127.0.0.1:7545',

    httpAgent: [Agent],
    timeout: 0,

    headers: undefined,

    connected: true,

    send: [Function],

   ......blah...blah

but...

truffle(development)> web3.eth.getAccounts

is working. please help

Yash Shukla
  • 375
  • 1
  • 4
  • 11
  • 2
    If web3.eth.getAccounts is working, then why don't you simply use it??? As of web3.js v1, web3.eth.accounts is deprecated. – goodvibration Jan 27 '19 at 08:23
  • I can use it but I am not able to choose any of the accounts specifically which I was able to do with 'web3.eth.accounts[0]" , please let me know the replacement for this? – Yash Shukla Jan 27 '19 at 09:06
  • You cannot use it, as it is undefined; you even specify it in your own question! 2. You've already found a replacement, and again - you even specify it in your own question!
  • – goodvibration Jan 27 '19 at 09:51