0

When I run truffle compile it stuck forever after compiling contracts . I am importing openzeppelin library and using infura , ropsten and metamask to deploy contract on testnet. . Here is the output

Compiling ./contracts/Migrations.sol...
Compiling ./contracts/obaidminttoken.sol...
Compiling zeppelin-solidity/contracts/math/SafeMath.sol...
Compiling zeppelin-solidity/contracts/ownership/Ownable.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/BasicToken.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/ERC20.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/MintableToken.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/StandardToken.sol...
Writing artifacts to ./build/contracts

Here is my truffle.js file

require('dotenv').config();
const HDWalletProvider = require("truffle-hdwallet-provider");
module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 7545,
      gas: 6500000,
      network_id: "5777"
    },
    ropsten: {
        provider: new HDWalletProvider(process.env.MNENOMIC, "https://ropsten.infura.io/v3/" + process.env.INFURA_API_KEY),
        network_id: 3,
        gas: 4500000
    },
  }
};
  • truffle compile just compiles. If you want to deploy, use truffle migrate – Raghav Sood Aug 1 '18 at 12:25
  • What is your Truffle version? – goodvibration Aug 1 '18 at 12:51
  • @goodvibration Truffle v4.1.8 (core: 4.1.9) Solidity v0.4.24 (solc-js) – mohammad obaid Aug 1 '18 at 12:57
1

Check that the filename is the same as the contract's name, eg. if the contract's name is : Voting, name the file voting.sol.
If that doesn't work, try deleting json files under build/contracts/ and run truffle compile again.

For more info check out https://github.com/trufflesuite/truffle-migrate/issues/14

  • Yes I have checked . I tried to run this command truffle migrate --network ropsten without compiling and it stuck at saving artifacts . One thing I want to ask do I need to change my 1_initial_migration.js or just 2_initial_migration.js file ? – mohammad obaid Aug 1 '18 at 13:06
0

This issue fixed by wrapping HDWallet provider in truffle.js file . Here is an updated truffle.js code

require('dotenv').config();
const HDWalletProvider = require("truffle-hdwallet-provider");
module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 7545,
      gas: 6500000,
      network_id: "5777"
    },
    ropsten: {
        provider:function() { return new HDWalletProvider(process.env.MNENOMIC, "https://ropsten.infura.io/v3/" + process.env.INFURA_API_KEY);},
        network_id: 3,
        gas: 4500000
    },
  }
};

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.