[Ethereum] Truffle + INFURA remote provider deployment. Migrations not running

contract-deploymentinfuratruffleweb3-providersweb3js

I am running into the same issue proposed by this question. I cannot resolve it because I am using a remote provider (INFURA), per this document.

My code looks like this:

var ethwallet = require('ethereumjs-wallet');
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");

// Import the raw private key of the admin
const keys = require('../test/keystores/keys.json');
const admin_key = keys.admin.privateKey;
const admin_addr = keys.admin.address;

// Add the admin key to the provider. This will unlock the account so it can
// deploy the contracts and run the tests.
var wallet = ethwallet.fromPrivateKey(Buffer.from(admin_key, 'hex'));
var engine = new ProviderEngine();

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

module.exports = {
  networks: {
    infura: {
      network_id: 5810,
      provider: engine,
      from: admin_addr
    },
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*"
    }
  }
};

And I am running:

truffle migrate --network infura

Which hangs indefinitely. This also happens if I run:

truffle compile --network infura

Or any other truffle action.

Is it possible to run this without a local node? I would like to deploy these to this network using the remote INFURA provider.

Best Answer

The answer to this problem should be adding two more lines, which you can find in the last answer here.

Related Topic