1
 const HDWalletProvider = require('truffle-hdwallet-provider');
 const Web3 = require('web3');
 const provider = new HDWalletProvider( 'passphrase', 'rinkeby.infura.io/v3/mytoken' );
 const web3 = new Web3(provider);
 const deploy = async () =>{ const accounts = await web3.eth.getAccounts(); } deploy();

gives

TypeError:Cannot read property 'map' of undefined at GetAccountsMethod.afterExecution

versions used:

 "solc": "^0.4.24",
 "truffle-hdwallet-provider": "^1.0.4",
 "web3": "^1.0.0-beta.46" 

any solution woud be grateful. Thanks in advance.

7
  • You're gonna have to do a little more than that (share more code, and share more efforts made investigating this problem) if you're hoping to get help here. Feb 20 '19 at 10:05
  • const HDWalletProvider = require('truffle-hdwallet-provider'); const Web3 = require('web3'); const provider = new HDWalletProvider( 'tomato rate sheriff course end labor topic above curious this rail group', 'rinkeby.infura.io/v3/ff9cefedf8924477a6d236e5e36fc06b' ); const web3 = new Web3(provider); const deploy = async () =>{ const accounts = await web3.eth.getAccounts(); } deploy();
    – arun
    Feb 20 '19 at 10:09
  • 4
    Are you sure it's a good idea to post those 12 words? Feb 20 '19 at 10:18
  • raised : github.com/ethereum/web3.js/issues/2405
    – Aniket
    Feb 21 '19 at 17:36
  • 1
    downgrade it to 1.0.0-beta.36, it will work.
    – Aniket
    Feb 21 '19 at 17:59
0

You might need to remove the truffle build in your directory

rm -R build/
0

I run into the same error and in my case I accidentally imported the dbg.json file instead of json file.

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.