1

I am trying to deploy a smart contract to the Kovan test network with the truffle framework. When I run truffle migrate --network kovan it just hangs for ages at the following place:

Running migration: 1_initial_migration.js
  Deploying Migrations...

My truffle.js file is as follows:

// 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 = "some words that are in the mnemonic that i use";
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://kovan.infura.io/MYACCESSCODE";
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: {
    kovan: {
      network_id: 42,    // Official kovan 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
  }
};

I can see that a transaction has been created at: [https://kovan.etherscan.io/txs?ca=0x8ade41c465fa645d84df4e319524e1f9fa366325], but when I try to connect with my dApp I get the Error Error: MyContract has not been deployed to detected network (network/artifact mismatch)

Would anyone have any suggestions?

Any help would be greatly appreciated.

Thanks!

  • How long is "ages"? – Mike Shultz Jul 15 '17 at 18:15
  • It never ends basically – Tom Murray Jul 15 '17 at 20:05
  • Yesterday we have some problems with infura access, some transactions will delay for hours. Switched to a local geth, and it started to work immediately. – Ismael Jul 15 '17 at 20:24
  • 2
    I've got it working :) thanks a lot for your help. Instead of using geth though, I used parity, and my truffle.js file was reduced to: require('babel-register'); module.exports = { networks: { development: { host: 'localhost', port: 8545, network_id: '*' // Match any network id }, kovan: { host: 'localhost', port: 8545, network_id: 42, gas: 4000000 } }, build: "webpack" } – Tom Murray Jul 16 '17 at 11:42

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.