when deploying to infura ropsten i get error

Running migration: 1_initial_migration.js
Deploying Migrations...
... 0x0ed88dd40f380a805ed0ba1b5b0a9d8178321ab6da9e5c0cb247f5700337b173
Migrations: 0xcfc4ba0488f20c7a2bb24e735f43e240bf249bc8
Saving successful migration to network...
  ... 0x471a1036236241c302cfa7b8dfcd011e106e221202b7c8c2586c3bf2d28c5546
Saving artifacts...
Running migration: 2_deploy_contracts.js

        return new Error(message);
Error: Invalid JSON RPC response: undefined
    at Object.InvalidResponse (/usr/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
    at RequestManager.send (/usr/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:61:1)
    at Eth.get [as accounts] (/usr/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/property.js:107:1)
    at module.exports (/home/josue/Desktop/projectX/ebay-on-ethereum-ipfs-starter-project/migrations/2_deploy_contracts.js:6:44)
    at /usr/lib/node_modules/truffle/build/webpack:/packages/truffle-migrate/index.js:82:1
    at /usr/lib/node_modules/truffle/build/webpack:/packages/truffle-require/require.js:101:1
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)`

this my truffle.js content


var HDWalletProvider = require("truffle-hdwallet-provider");
var mnemonic = process.env["NEMONIC"];
var tokenkey = process.env["ENDPOINT_KEY"];

module.exports = {
  networks: {
    development: {
      host: "",
      port: 8545,
      network_id: "*"
    ropsten: {
      host: "localhost",
      provider: function() {
        return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/" + tokenkey)
      network_id: 3,     //make sure this gas allocation isn't over 4M, which is the max
      gas: 400000,
      gasPrice: 1000,
    rinkeby: {
      host: "localhost",
      provider: function() {
        return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/" + tokenkey)
      network_id: 4,
      gas: 67500000,


and my 2_deploy_contract.js

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

module.exports = function(deployer) {
  deployer.deploy(EcommerceStore, web3.eth.accounts[9]);


var mnemonic = process.env["NEMONIC"];

Confirm your mnemonic is a 12-word phrase and there is no typo in the variable name.

You will need to have some Ether in the wallet so you can pay for gas.

Gas: 400000 may be too light. You can safely increase that because a surplus is returned in most cases. I would increase that to rule it out, especially on testnet.

It's vital that your contract actually compiles or it will abort like this. Also, if there are any conditionals in the constructor (require(...)) make sure all conditions are met.

This line:

deployer.deploy(EcommerceStore, web3.eth.accounts[9]);

This is possibly trying to pass in address(0) (0x0) and a constructor probably isn't happy with that if it is checking require(addressIn != address(0)); (as it should).

Try this (in 2_deploy_contracts):

module.exports = function(deployer, network, accounts)

Then use accounts[9] instead of web3.eth.accounts[9].

Hope it helps.


Hope it helps.

| improve this answer | |

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.