7

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)

  • 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 – Greg Jeanmart May 17 '18 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 May 17 '18 at 15:29
  • have you tried --reset --compile-all ? – Greg Jeanmart May 17 '18 at 15:42
  • Is that truffle compile --reset --compile-all ? – simbro May 17 '18 at 15:45
  • 1
    truffle migrate --network ropsten --reset --compile-all --verbose-rpc – Greg Jeanmart May 17 '18 at 15:46
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!

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!

1

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!

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, privacy policy and cookie policy

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