1

Unable to deploy contract on Rinkeby network using infura and mnemonic of metamask account.

I am using Atom as IDE for writing smart contract using solidity.

As soon as I execute node deploy.js, I get error as invalid member of stdlib I tried reinstalling npm, solc, truffle-hdwallet-provider but to no luck. Even the console.log does not print anything on console.

enter image description here

Below is the dependency in my package.json:

"dependencies": { "ethereumjs-testrpc": "^6.0.3", "ganache-cli": "^6.4.3", "mocha": "^6.1.4", "python": "0.0.4", "solc": "^0.4.25", "truffle-hdwallet-provider": "^1.0.8", "web3": "^1.0.0-beta.37" }

deploy.js

   const HDWalletProvider = require('truffle-hdwallet-provider');
   const Web3 = require('web3');
   const {interface,bytecode} = require('./compile');

   const provider = new HDWalletProvider(
     'my mnenonic',
     'infure URL'
   );

   const web3 = new Web3(provider);

   const deploy = async()=>{

   const accounts = await web3.eth.getAccounts();

   console.log('Attempting to deploy from account',accounts[0]);

   const result = await new web3.eth.Contract(JSON.parse(interface))
    .deploy({data: bytecode, arguments: ['Hi there!!'] })
    .send({gas: '1000000', from: accounts[0] });

   console.log('Contract deployed to', result.options.address);

  };
  deploy();
3
  • Seems to be a problem with dependencies, try removing node_modules and running npm install.
    – Ismael
    May 5, 2019 at 20:40
  • Already tried that. Didn't work. Seems like there is some sort of mismatch between solc, truffle-hdwallet-provider and web3.
    – Ankur B
    May 9, 2019 at 15:58
  • It is hard to recommend somthing to try without a way to reproduce your error. A couple of things: * "ethereumjs-testrpc" is redundant with "ganache-cli" so it is better to remove it, * There are several bugs affecting recent versions of web3 v1.0, probably you want to force an specific version "web3": "1.0.0-beta.37" (ie remove the ^ in front of the version), if that doesn't work try with "1.0.0-beta.34".
    – Ismael
    May 9, 2019 at 16:12

2 Answers 2

0

Try install truffle hdwallet like this

$ npm install @truffle/hdwallet-provider

then import hadwallet like this

const HDWalletProvider = require('@truffle/hdwallet-provider');

0

It's ganache and/or Jest doing that to me. This issue is related: https://github.com/facebook/jest/issues/2549

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.