0

I'm trying to deploy a smart contract to the main Ethereum network, and I'm having trouble actually getting my front-end to work. I'm using Truffle, Geth, Infura, and web3js.

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

var mnemonic = "hidden_for_obvious_reasons";

module.exports = {
  networks: {
    live: {
      network_id: 1,
      provider: new HDWalletProvider(mnemonic, "https://mainnet.infura.io/my_api_key")    
    }   
  }
};

Inside Adoption.js, which is the artifact for my contract, I see the following:

  "networks": {
    "3": {
      "events": {},
      "links": {},
      "address": "0xf45599d4f5a0e9b3f8f4b45012f96e038e7208e6"
    }

I think that has something to do with it.

My contract deploys without any issues and I can see it on etherscan here.

My 1_initial_migration.js file:

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

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

My 2_deploy_contracts.js file:

var Adoption = artifacts.require("Adoption");

module.exports = function(deployer) {
  deployer.deploy(Adoption, {gas:2000000});
};

I'm just trying to figure out why my front-end can't interact with my contract. Here's the console output in the browser:

truffle-contract.js:425 Uncaught (in promise) Error: Contract has not been deployed to detected network (network/artifact mismatch) at truffle-contract.js:425 at <anonymous>

  • 1
    Network Id 3 is Ropsten. How is your migration script? Do you use async/await in it (truffle has issues with it in the deploy script github.com/trufflesuite/truffle/issues/501)? It is possible that migration succeeded but the artifacts didn't get updated. – Ismael Feb 24 '18 at 5:43
  • @Ismael I updated my question with the migration script. – dougdimmadome Feb 24 '18 at 6:21
  • The other famous issue with truffle is that sometimes it will stop updating the artifacts in the build directory. While testing I just remove the whole directory just in case. For production you may try firs to update the artifacts, copy the configuration for ropsten "3", and set it to mainnet network id "1" then replace address by the deployed address. – Ismael Feb 24 '18 at 7:00
  • @Ismael I think the config for my truffle.js file should be correct, but now I'm having the following issue: insufficient funds for gas * price + value. I'm using the same MetaMask mnemonic as I was before, and that wallet has about .07 eth in it. Do you know why that may be happening? – dougdimmadome Feb 24 '18 at 7:19
  • From your truffle.js, you are connecting to an instance of geth running in port 8546. In that case truffle will use the first account in geth and not the mnemonic seed. To use the mnemonic you have to configure a provider following the instruction in the readme. How did you launch geth to connect to mainnet? – Ismael Feb 24 '18 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.