3

I am using truffle: "^4.1.14" and ganache-cli version "^6.1.8". When I try to migrate to ganache cli network, it works without a problem. But when I try to migrate to Rinkeby, it always fails. The error message says TypeError: Cannot read property 'bind' of undefined. The problematic line is buried somewhere deep in webpack, and I can't get to that script to inspect it or console.log it.

The relevant part of truffle.js looks like this

rinkeby_infura: {
      provider: function() {        
        // using process.env.MNENOMIC would be safer, but this is test project
        const mnemonic = require('./.mnemonic');
        const apiKey = require('./.infura_api_key');
        return new HdWalletProvider(mnemonic, 'https://rinkeby.infura.io/' + apiKey);
      },
      network_id: 4,      
      gas: 4612388 // Gas limit used for deploys
    },

The full stack trace of the exception is below. It probably has something to do with connecting to Rinkeby via provider, at least from what I've googled so far. But I am unable to make it work.

$ ./node_modules/.bin/truffle migrate --network rinkeby_infura

C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-provider\wrapper.js:26
    var originalSendAsync = provider.sendAsync.bind(provider);
^
TypeError: Cannot read property 'bind' of undefined
    at Object.wrap (C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-provider\wrapper.js:26:1)
    at Object.wrap (C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-provider\index.js:7:1)
    at Object.create (C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-provider\index.js:21:1)
    at Config.get [as provider] (C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-config\index.js:165:1)
    at Object.detect (C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-core\lib\environment.js:46:1)
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-core\lib\commands\migrate.js:91:1
    at finished (C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-workflow-compile\index.js:53:1)
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-compile\index.js:314:1
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:158:1
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:3888:1
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:473:1
    at replenish (C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:1006:1)
    at iterateeCallback (C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:995:1)
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:969:1
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:3885:1
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:154:1
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:1140:1
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:473:1
    at iteratorCallback (C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:1064:1)
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:969:1
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\~\async\dist\async.js:1137:1
    at C:\src\personal\ens-registrar\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:133:1
    at FSReqWrap.oncomplete (fs.js:155:5)
1
  • The error message states in provider.sendAsync.bind that you are trying to read bind of undefined, so it is sendAsync is undefined. I remember that web3 0.20 -> 1.0 changed from provider.sendAsync() to provider.send() so perhaps there are some dependencies in your project that are using the wrong version of web3.
    – Ismael
    Commented Feb 20, 2019 at 21:40

2 Answers 2

0

In my opinion Truffle is having trouble opening your mnemonic / Infura API key files. Is it working if you use directly the mnemonic and the API key instead of the variables?

Also I recommend you to use dotenv and process.env (even with a test project), it would be easier to handle future updates!

1
  • I know that using it in ENV variables would be safer, but this is just a test project, and this was easier set up. I've tried to include API key and mnemonic directly, but it did not change anything Commented Nov 14, 2018 at 12:27
0

What are the files for the environment variables? If they are just plain text, you may need to fix that. You could just create a single json or js file, add the vars as key/value pairs and export it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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