0

I'm trying to deploy my contracts to the ropsten test network, but I get this error.

the message error :

C:\Users\acer\test>truffle migrate --reset --network ropsten
Using network 'ropsten'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0xf9d9daf3c904e239bc27fd70a51916e1dd954238215f631e7f341e1270fa55ab
Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (C:\Users\acer\test\node_modules\web3\lib\web3\errors.js:35:16)
    at XMLHttpRequest.request.onreadystatechange (C:\Users\acer\test\node_modules\web3\lib\web3\httpprovider.js:115:32)
    at XMLHttpRequest.dispatchEvent (C:\Users\acer\test\node_modules\xhr2\lib\xhr2.js:76:20)
    at XMLHttpRequest._setReadyState (C:\Users\acer\test\node_modules\xhr2\lib\xhr2.js:422:14)
    at XMLHttpRequest._onHttpRequestError (C:\Users\acer\test\node_modules\xhr2\lib\xhr2.js:669:14)
    at ClientRequest.request.on (C:\Users\acer\test\node_modules\xhr2\lib\xhr2.js:499:23)
    at ClientRequest.emit (events.js:182:13)
    at TLSSocket.socketErrorListener (_http_client.js:391:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  Migrations: 0x116940816fb03041b4fc9018dffdef346fe0932b
Saving artifacts...
Running migration: 2_migration.js
  Replacing DinarCoin...
  ... 0x8b1ddbc08abb3561be6df6148a7a5cf9006e1e6ae520dd9e8a67713ed6af33cd
  DinarCoin: 0xeb43d979ec0d3d004c5d50c202e2cbec02edf2e1
Saving artifacts...
  Deploying DinarCrowdsale...
  ... 0x949fff0717b07829fd62f5df0fb9f21ad1ed2d4b9665704c75aab206fcf49921
Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (C:\Users\acer\test\node_modules\web3\lib\web3\errors.js:35:16)

Please How can I fix this problem ? and Thank you in advance.

6
  • can you add your truffle config network settings for ropsten
    – Sanjay S B
    Jul 19, 2019 at 4:54
  • @SanjaySB I set up a HDWalletProvider and connect it to infura and ropeston testnet Jul 19, 2019 at 13:21
  • The error could be in the migration code or the config set up. Without sharing anything how can one debug your code.
    – Sanjay S B
    Jul 19, 2019 at 13:32
  • truffle-config.js : Jul 20, 2019 at 15:02
  • @SanjaySB Sir, when I deploy to ganache local testnet, is work without problem !!! Jul 20, 2019 at 15:13

1 Answer 1

0

@SanjaySB,

truffle-config.js file :

require('babel-register');
require('babel-polyfill');
require('dotenv').config();
const HDWalletProvider = require('truffle-hdwallet-provider');

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*', // eslint-disable-line camelcase
    },
    ganache: {
      host: 'localhost',
      port: 8545,
      network_id: '*', // eslint-disable-line camelcase
    },
    ropsten: {
      provider: function() {
        return new HDWalletProvider(
          process.env.MNEMONIC,
          `https://ropsten.infura.io/v3/9ffa4f404f6c47bf9dd98937dc4dee36`
        )
      },
      gas: 5000000,
      gasPrice: 25000000000,
      network_id: 3, 
      skipDryRun: true  
    },
    rinkeby: {
        provider: function() { 
         return new HDWalletProvider(process.env.MNEMONIC, "https://rinkeby.infura.io/v3/9ffa4f404f6c47bf9dd98937dc4dee36");
        },
        network_id: 4,
        gas: 4500000,
        gasPrice: 10000000000,
    }

  },
  solc: {

    version: "0.4.24",
      settings: {
        optimizer: {
          enabled: true,
          runs: 200  // Optimize for how many times you intend to run the code
        },

      }
  }
};

Migration file ;

module.exports = async function(deployer, network, accounts) {
  const _name = "Dinar Coin";
  const _symbol = "DNC";
  const _decimals = 18 ;
  await deployer.deploy(DinarCoin, _name, _symbol, _decimals);
  const deployedToken = await DinarCoin.deployed();

  const latestTime = (new Date).getTime();

  const _rate           = 500;
  const _wallet         = '0x7b179f369451782679aCc04f9799193E67f14f74'; // TODO: Replace me
  const _token          = deployedToken.address;
  const _openingTime    = latestTime + duration.minutes(1);
  const _closingTime    = _openingTime + duration.weeks(10);
  const _cap            = ether(100);
  const _goal           = ether(50);
  const _foundersFund   = '0x7b179f369451782679aCc04f9799193E67f14f74'; // TODO: Replace me
  const _foundationFund = '0x7b179f369451782679aCc04f9799193E67f14f74'; // TODO: Replace me
  const _partnersFund   = '0x7b179f369451782679aCc04f9799193E67f14f74'; // TODO: Replace me
  const _releaseTime    = _closingTime + duration.days(1);

  await deployer.deploy(
    DinarCrowdsale,
    _rate,
    _wallet,
    _token,
    _cap,
    _openingTime,
    _closingTime,
    _goal,
    _foundersFund,
    _foundationFund,
    _partnersFund,
    _releaseTime
  );

  return true;
};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.