I am giving following commands at Truffle console but I am getting "undefined" message:

> $ truffle console
> You can improve web3's peformance when running  Node.js versions older
> than 10.5.0 by   installing   the (deprecated)  scrypt package in your
> project 
> truffle(ganache)> let accounts =await web3.eth.getAccounts()
> undefined

Truffle version is:

> truffle(ganache)> truffle version 
> Truffle v5.1.27 (core: 5.1.27)
>  Solidity v0.5.16 (solc-js) Node v8.10.0 Web3.js v1.2.1
>  truffle(ganache)>

Somebody please guide me.


  • 2
    The undefined printed in the console is from the use of let. If you examine the variable accounts it was correctly assigned. For example type let a = 22 and it will print undefined.
    – Ismael
    Jun 14, 2020 at 15:49

1 Answer 1


I think you are trying to get the accounts of ganache using JavaScript in truffle console I advise you to write the following snippet


and then you can access the list of accounts in truffle console using the following command

  • Your answer helped me to get all the accounts but then I typed "acc1 = accounts[0]" at the console and it worked.
    – zak100
    Jun 16, 2020 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.