While trying to deploy my erc20 contract on ropsten,I am not able to see transaction at https://ropsten.etherscan.io

Steps I followed

1) My Config file :

networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*" // Match any network id
    },

    ropsten: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "3",
      gas: 500000
    }
  }

2) Copied my ropsten network address using mnemonics from metamask to Ganache.

3) Ran following command

truffle migrate --network ropsten --reset

4) Contract got deployed successfully with following output


Using network 'ropsten'.

Running migration: 1_initial_migration.js
  Replacing Migrations...
  ... 0x758038b5f32e08870b65c39d7fb8b2413e310b76437141920035d32eb071fb24
  Migrations: 0x619c935ee4bb707412fe5cd14063548ef1fca453
Saving successful migration to network...
  ... 0xe588beec7c7ab9e71dd38792a439b5b15d00cb14c2f444512bcb5b2025681dd2
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Replacing Migrations...
  ... 0xe625770acec3c060804c8a1e03396b9349074c4c8fd9cb11cb14cc14b1fb0a82
  Migrations: 0x7336ef499b79fd25f8aa688c4ea9a0335b33a8f9
Saving successful migration to network...
  ... 0x714203dca5e0481fbab2a31cff7800b9c8db1bef28a03c04c21cdbc512497f0e
Saving artifacts...

Anything I am missing here. Thanks in advance

  • 1
    is the host at 127.0.0.1:8545 connected to the Ropsten testnet? – Henk Aug 16 at 9:43
  • 1
    Yes, and why do you mention Ganache? That sounds suspicious. – Xavier Leprêtre B9lab Aug 16 at 9:45
  • I had changed network id in ganache to 3. looks like that is not something i should be doing. can you guide me how to deploy to ropsten through my local machine. – sumit Aug 16 at 9:49
  • 1
    Ganache is a blockchain simulator, you can't deploy smart contracts to the Ropsten testnet with Ganache. You'll either have to set up your own geth node that is connected to the Ropsten network or a combination of truffle-hdwallet-provider and infura to deploy your contracts to Ropsten – Henk Aug 16 at 10:00
  • Thanks. Was trying to install truffle-hdwallet-provider this morning , got some error. Let me check again. – sumit Aug 16 at 10:01
up vote 0 down vote accepted

Ganache is a blockchain simulator, you can't deploy smart contracts to the Ropsten testnet with Ganache. You'll either have to set up your own geth node that is connected to the Ropsten network or a combination of truffle-hdwallet-provider and infura to deploy your contracts to Ropsten.

Here's an example truffle-config.js:

var HDWalletProvider = require("truffle-hdwallet-provider");

const constants = {
    infuraAccessToken: "[YOUR INFURA ACCESS TOKEN]",
    mnemonic: "[YOUR SECRET MNEMONIC]"
}

let truffleOptions = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*", // Match any network id
    },
    ropsten: {
      provider: () => new HDWalletProvider(constants.mnemonic, "https://ropsten.infura.io/" + constants.infuraAccessToken),
      network_id: 3,
      gas: 4700000, // Please check the current block gas limit and set this value accordingly
    },
  }
};

module.exports = truffleOptions;
npm i -g etherlime
etherlime init
etherlime compilе
etherlime deploy --network=ropsten  --secret={PrivateKey}

Also you should set the path your contract in deploy.js

const etherlime = require('etherlime');

const TestContract = require('./TestContract.json'); //Path to your contract

const defaultConfigs = {
    gasPrice: 20000000000,
    gasLimit: 4700000
}

const deploy = async (network) => {

    const deployer = new etherlime.InfuraPrivateKeyDeployer('Your Private Key Goes Here', 'ropsten', 'Your Infura API Key', defaultConfigs);

    const result = await deployer.deploy(TestContract, '0xda8a06f1c910cab18ad187be1faa2b8606c2ec86', 1539426974);
}

If you have any issues read the Documentation. Good luck!

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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