I'm trying to connect to rinkeby using the following code:

const HDWalletProvider = require('truffle-hdwallet-provider')
const Web3 = require('web3')
const secrets = require("./secret.json");

const provider = new HDWalletProvider(
  'https://rinkeby.infura.io/' + secrets.infura
web3 = new Web3(provider);
(async () => {
  console.log(await web3.eth.getAccounts()); //returns undefined

Note its very similar to the github examples but it fails with the following error

            callback(err, property.formatOutput(result));
TypeError: callback is not a function

I've also tried to use ganache but i get a very similar error when i call web3.eth.getAccounts();

const ganache = require('ganache-cli')
const web3 = new Web3(ganache.provider());


callback is not a function
    at /projects/campaignM/node_modules/web3/lib/web3/property.js:119:13
  • Are you using web3 v1.0? Until a few months ago it was not compatible with HDWalletProvider. – Ismael Mar 17 '18 at 0:54
  • I think that was the issue ! – Arash Kiani May 9 '18 at 12:39

Your Answer

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

Browse other questions tagged or ask your own question.