[Ethereum] truffle migrate hanging on Deploying Migrations

metamaskmigrationropstentruffleweb3-providers

I am deploying a contract on Ropsten Network,These are my settings

2_deploy_contracts.js

var SafeMath = artifacts.require("./SafeMath.sol");
var TahaCoin = artifacts.require("./TahaCoin.sol");
var Crowdsale = artifacts.require("./Crowdsale.sol");
module.exports = function(deployer) {
var owner = web3.eth.accounts[0];
var wallet = web3.eth.accounts[1];

//var owner = '0x398DB5039aA7f064a8cBDe5c302E09E2cAc46487';
//var wallet = '0x6A0a14e7aAF404D0E5Cc118ECA740568d936fC9F';

console.log("Owner address: " + owner); 
console.log("Wallet address: " + wallet);   

deployer.deploy(SafeMath, { from: owner });
deployer.link(SafeMath, TahaCoin);
return deployer.deploy(TahaCoin, { from: owner }).then(function() {
    console.log("TahaCoin address: " + TahaCoin.address);
    return deployer.deploy(Crowdsale, TahaCoin.address, wallet, { from: owner }).then(function() {
        console.log("Crowdsale address: " + Crowdsale.address);
        return TahaCoin.deployed().then(function(coin) {
            return coin.owner.call().then(function(owner) {
                console.log("TahaCoin owner : " + owner);
                return coin.transferOwnership(Crowdsale.address, {from: owner}).then(function(txn) {
                    console.log("TahaCoin owner was changed: " + Crowdsale.address);        
                });
            })
        });
    });
});
};

truffle-config.js

// Allows us to use ES6 in our migrations and tests.
require('babel-register')
var bip39 = require("bip39");
var hdkey = require('ethereumjs-wallet/hdkey');
var ProviderEngine = require("web3-provider-engine");
var WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js');
var Web3Subprovider = require("web3-provider-engine/subproviders/web3.js");
 var Web3 = require("web3");

 // Get our mnemonic and create an hdwallet
 var mnemonic = "My phrase  12 words  12 words 12 words";
   var hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic));

 // Get the first account using the standard hd path.
 var wallet_hdpath = "m/44'/60'/0'/0/";
 var wallet = hdwallet.derivePath(wallet_hdpath + "0").getWallet();
 var address = "0x" + wallet.getAddress().toString("hex");

 var providerUrl = "https://ropsten.infura.io/";
 var engine = new ProviderEngine();
 engine.addProvider(new WalletSubprovider(wallet, {}));
 engine.addProvider(new Web3Subprovider(new 
 Web3.providers.HttpProvider(providerUrl)));
 engine.start(); // Required by the provider engine.

 module.exports = {
    networks: {
     ropsten: {
        network_id: 3,    // Official ropsten network id
        provider: engine, // Use our custom provider
        from: address,     // Use the address we derived
        gas: 3000000
         }
        },
     rpc: {
     // Use the default host and port when not using ropsten
        host: "localhost",
        port: 8545
        }
       };

important things

  1. Migration was created by my Wallet on Ropsten
  2. I have tow accounts on MetaMask
  3. I have enough gas "22ETH" in my deployer account
  4. i used pragma solidity ^0.4.11 on my contract files

enter image description here

Best Answer

From line 13 in your migration script, please try the following changes for the subsequent three lines:

deployer.deploy(TahaCoin, { from: owner }).then(function(instance) {

console.log("TahaCoin address: " + TahaCoin.address);
return deployer.deploy(Crowdsale, TahaCoin.address, wallet, { from: owner }).then(function(instance) {

Please report if this got you a step further.

Related Topic