Smart contract deployment TypeError

Hi,

I try to run an Ethereum Proof of Authority on the Micrsoft Azure cloud. And now I startet with the simple to tutorial, to check if everythin works.

But I get with the truffle command: truffle migrate --network poa always this error:

Starting migrations...
======================
> Network name:    'poa'
> Network id:      10101010
> Block gas limit: 0x2faf080


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    ...
   > Blocks: 0            Seconds: 0
   > contract address:    ...
   > block number:        10562
   > block timestamp:     1570007336
   > account:             ...
   > balance:             0
   > gas used:            261393
   > gas price:           0 gwei
   > value sent:          0 ETH
   > total cost:          0 ETH


   ⠴ Saving migration to chain.
C:\ETH\node_modules\web3-provider-engine\node_modules\async\internal\eachOfLimit.js:61
                        callback(null);
                        ^
TypeError: finished is not a function
    at C:\ETH\node_modules\web3-provider-engine\index.js:157:9
    at C:\ETH\node_modules\web3-provider-engine\node_modules\async\internal\once.js:12:16
    at replenish (C:\ETH\node_modules\web3-provider-engine\node_modules\async\internal\eachOfLimit.js:61:25)
    at C:\ETH\node_modules\web3-provider-engine\node_modules\async\internal\eachOfLimit.js:71:9
    at eachLimit (C:\ETH\node_modules\web3-provider-engine\node_modules\async\eachLimit.js:43:36)
    at C:\ETH\node_modules\web3-provider-engine\node_modules\async\internal\doLimit.js:9:16
    at end (C:\ETH\node_modules\web3-provider-engine\index.js:134:5)
    at C:\ETH\node_modules\web3-provider-engine\subproviders\provider.js:18:32
    at XMLHttpRequest.request.onreadystatechange (C:\ETH\node_modules\web3-providers-http\src\index.js:96:13)
    at XMLHttpRequestEventTarget.dispatchEvent (C:\ETH\node_modules\xhr2-cookies\xml-http-request-event-target.ts:44:13)
    at XMLHttpRequest._setReadyState (C:\ETH\node_modules\xhr2-cookies\xml-http-request.ts:219:8)
    at XMLHttpRequest._onHttpResponseEnd (C:\ETH\node_modules\xhr2-cookies\xml-http-request.ts:345:8)
    at IncomingMessage.<anonymous> (C:\ETH\node_modules\xhr2-cookies\xml-http-request.ts:311:39)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1129:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Is use this truffle-config.js:

/**
 * Use this file to configure your truffle project. It's seeded with some
 * common settings for different networks and features like migrations,
 * compilation and testing. Uncomment the ones you need or modify
 * them to suit your project as necessary.
 *
 * More information about configuration can be found at:
 *
 * truffleframework.com/docs/advanced/configuration
 *
 * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider)
 * to sign your transactions before they're sent to a remote public node. Infura accounts
 * are available for free at: infura.io/register.
 *
 * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
 * public/private key pairs. If you're publishing your code to GitHub make sure you load this
 * phrase from a file you've .gitignored so it doesn't accidentally become public.
 *
 */

const HDWalletProvider = require('@truffle/hdwallet-provider');
// const infuraKey = "fj4jll3k.....";
//
// const fs = require('fs');
// const mnemonic = fs.readFileSync(".secret").toString().trim();
const rpc_endpoint = "http://....azure.com:8540";
const mnemonic = "...";

module.exports = {
  /**
   * Networks define how you connect to your ethereum client and let you set the
   * defaults web3 uses to send transactions. If you don't specify one truffle
   * will spin up a development blockchain for you on port 9545 when you
   * run `develop` or `test`. You can ask a truffle command to use a specific
   * network from the command line, e.g
   *
   * $ truffle test --network <network-name>
   */

  networks: {
    // Useful for testing. The `development` name is special - truffle uses it by default
    // if it's defined here and no other network is specified at the command line.
    // You should run a client (like ganache-cli, geth or parity) in a separate terminal
    // tab if you use this network and you must also set the `host`, `port` and `network_id`
    // options below to some value.
    //
    development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
    },

    // Another network with more advanced options...
    // advanced: {
      // port: 8777,             // Custom port
      // network_id: 1342,       // Custom network
      // gas: 8500000,           // Gas sent with each transaction (default: ~6700000)
      // gasPrice: 20000000000,  // 20 gwei (in wei) (default: 100 gwei)
      // from: <address>,        // Account to send txs from (default: accounts[0])
      // websockets: true        // Enable EventEmitter interface for web3 (default: false)
    // },

    // Useful for deploying to a public network.
    // NB: It's important to wrap the provider as a function.
    // ropsten: {
      // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`),
      // network_id: 3,       // Ropsten's id
      // gas: 5500000,        // Ropsten has a lower block limit than mainnet
      // confirmations: 2,    // # of confs to wait between deployments. (default: 0)
      // timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
      // skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
    // },

    // Useful for private networks
    poa: {
     provider: () => new HDWalletProvider(mnemonic, rpc_endpoint),
     network_id: 10101010,   // This network is yours, in the cloud.
     production: true,    // Treats this network as if it was a public net. (default: false)
	 gasPrice: '0x0',
	 gas: 0
    }
  },

  // Set default mocha options here, use special reporters etc.
  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
      // version: "0.5.1",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      // settings: {          // See the solidity docs for advice about optimization and evmVersion
      //  optimizer: {
      //    enabled: false,
      //    runs: 200
      //  },
      //  evmVersion: "byzantium"
      // }
    }
  }
}

These are my migration files:
1_initial_migration.js:
const Migrations = artifacts.require(“Migrations”);

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

2_deploy_contracts.js
var PostBox = artifacts.require("./PostBox.sol");

module.exports = function(deployer) {
	deployer.deploy(PostBox);
};

This is the line 54 to 68 from eachOfLimit.js
function replenish() {
looping = true;
while (running < limit && !done) {
var elem = nextElem();
if (elem === null) {
done = true;
if (running <= 0) {
callback(null);
}
return;
}
running += 1;
iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback));
}
looping = false;
}

Does someone has an idea how to fix this?

Thanks and bye

Moe

The migrations dry-run (simulation) doesn’t show any errors.

I follow this documentation:

Seems like there is a problem with web3-provider-engine. I think this is used by truffle-hdwallet-provider and/or web3.

Try:

  • Updating Truffle CLI (npm update -g truffle)
  • Updating truffle-hdwallet-provider (npm update hdwallet-provider)

Also try to replace:

var PostBox = artifacts.require("./PostBox.sol");

By this:

var PostBox = artifacts.require("PostBox.sol");

What happen if you try to deploy locally? does it work?

Thanks, for your reply. I updated truffle. For the hdwallet-provider, I only changed the npm update statement to @truffle/hdwallet-provider.

But I still get the same error. I have to deploy locally. And see if this works.

I deployed the contract locally and everythin works smoothly. The code or framework isn’t probably the problem. I don’t have any idea, but I would expect the connection to the Azure cloud is the reason.

Any ideas?

Good that it works locally at least.

I havent used Azure cloud, I have no other ideas :frowning:
Do you absolutely need to use them, or can you deploy with another service provider?