8

When I run the following command I receive no output whatsoever:

truffle migrate --network ropsten

This is just after creating a new project using truffle init and creating a single contract.

When I run truffle develop and run the migrate command from the console, everything works fine.

This is the contents of my truffle.js file:

var HDWalletProvider = require("truffle-hdwallet-provider");

var mnemonic = "my twelve word mnemonic......";

module.exports = {
  networks: {
    ropsten: {
      provider: function() {
        return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/xxxxxxxxxxxxx")
      },
      network_id: 3
    },
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    }
  }
};

I'm on Ubuntu 16.04 and the latest version of truffle 4.1.8.

(and yes, I have funded my account on Ropsten with Ether from the faucet)

6
  • No output ? Any exit code ? You can try using --verbose-rpc to get some debug traces. Otherwise, if you want to reset the build from scratch, try --reset --compile-all Commented May 17, 2018 at 15:17
  • This is what I get: localhost:~/testdapp$ truffle migrate --network ropsten --verbose-rpc > { > "jsonrpc": "2.0", > "id": 1, > "method": "eth_accounts", > "params": [] > }
    – simbro
    Commented May 17, 2018 at 15:29
  • have you tried --reset --compile-all ? Commented May 17, 2018 at 15:42
  • Is that truffle compile --reset --compile-all ?
    – simbro
    Commented May 17, 2018 at 15:45
  • 2
    truffle migrate --network ropsten --reset --compile-all --verbose-rpc Commented May 17, 2018 at 15:46

4 Answers 4

2

This is how i do it to deploy on Kovan for example, changing the infura link you can deploy on every testnets. Works for me totally fine:

const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const { interface, bytecode } = require ('./compile'); //That files come from the compile.js you can see it below.

const provider = new HDWalletProvider(
    '12 words mneumonic',
    'https://kovan.infura.io/XXXXXXXXXXXX'
);

const web3 = new Web3(provider);

const deploy = async ()=> { //Create that function to use async & await
    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})
        .send({ gas: '30000000', from: accounts[0]});

        console.log('Contract deployed to', result.options.address);
        console.log(interface);//We pass the ABI through the console to be able to use it to build the javascript object that emulates the contract on our react code.

};
deploy();

Here I leave you the compile.js just in case you need it.

    const path = require('path'); // Helps to find the path to the contract across whatever OS you are using form compile.js to xxx.sol files
    const fs = require('fs'); // Load the FileSystem Module.
    const solc = require('solc');

    const contractPath = path.resolve(__dirname, 'contracts', 'Contracts_Remix.sol'); //Creation of cross SO's path.

    const source = fs.readFileSync(contractPath, 'utf8'); 
    //We compile the source code, of 1 single contract and showed the bytecode and the ABI by console to examine it.
    console.log(solc.compile(source),1); 
    module.exports = solc.compile(source).contracts[':Your_contract_name']; 
//We only call the contract we want to deploy.

Hope it helps!

2

I was having the same issue, but in my case, I had incorrectly set my infura endpoint environment variable to my secret key instead of my project id. In case it helps anyone else reading this, ensure your infura endpoint is correct!

1
  • This was the error in my case. My rpc url was formatted incorrectly. In order to reference variables in the rpc url in the ropsten provider, it needs to be surrounded by 'back-ticks' instead of single quotes, ex: return new HDWalletProvider(process.env.MNEMONIC, `ropsten.infura.io/v3/${process.env.INFURA_API_KEY}`);
    – broadbear
    Commented May 18, 2021 at 14:24
1

Not getting anywhere with this, seems the migration gets stuck on the first part:

> {
>   "jsonrpc": "2.0",
>   "id": 1,
>   "method": "eth_accounts",
>   "params": []
> }

It could be because I am behind a corporate proxy, but I can't tell from the output. Stumped!

0

I was having similar issue and lowering the hdwallet provider version solved the problem (truffle-hdwallet-provider from 1.0.7 to 1.0.6.)

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.