0

I follow the book Ethereum from Gavin Wood and when i use truffle migrate --network ganache it gives me following error;

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type undefined
at Function.from (buffer.js:208:11)
at new Buffer (buffer.js:183:17)
at Object.<anonymous> (/home/superadmin/kittycoin/truffle-config.js:12:27)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at Object.require (internal/modules/cjs/helpers.js:20:18)
at Function.load (/home/superadmin/.nvm/versions/node/v10.13.0/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:161:1)
at Function.detect (/home/superadmin/.nvm/versions/node/v10.13.0/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:150:1)
at Object.run (/home/superadmin/.nvm/versions/node/v10.13.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:189:1)
at Command.run (/home/superadmin/.nvm/versions/node/v10.13.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:136:1)
at Object.<anonymous> (/home/superadmin/.nvm/versions/node/v10.13.0/lib/node_modules/truffle/build/webpack:/packages/core/cli.js:51:1)
at __webpack_require__ (/home/superadmin/.nvm/versions/node/v10.13.0/lib/node_modules/truffle/build/webpack:/webpack/bootstrap:19:1)
at /home/superadmin/.nvm/versions/node/v10.13.0/lib/node_modules/truffle/build/webpack:/webpack/bootstrap:83:1
at Object.<anonymous> (/home/superadmin/.nvm/versions/node/v10.13.0/lib/node_modules/truffle/build/cli.bundled.js:89:10)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
Truffle v5.1.27 (core: 5.1.27)
Node v10.13.0

I found out it comes from this part in my truffle-config.js

var ropstenPrivateKey = new Buffer(process.env["ROPSTEN_PRIVATE_KEY"], "hex")
var ropstenWallet = Wallet.fromPrivateKey(ropstenPrivateKey);
var ropstenProvider = new WalletProvider(ropstenWallet, "https://ropsten.infura.io/");`

my .env looks like this;

ROPSTEN_PRIVATE_KEY="ABC123"
MAINNET_PRIVATE_KEY="ABC123"

Does anyone have an idea?

  • 1
    Yeah, here's an idea: change process.env["ROPSTEN_PRIVATE_KEY"] to "ABC123" and check whether or not the problem persists. This debug-method is also known as "eliminating possible causes of the problem in order to discover which one of them is causing it". It will fail to lead you to the conclusion only if there is more than one cause which can trigger the problem independently of all the other causes. You should really consider using it always. – goodvibration May 26 at 16:24

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.