3

Why can't deployed contract be found?

My node:

admin.nodeInfo
{
  ...,
  protocols: {
    eth: {
      difficulty: 36521801351,
      genesis: "...",
      head: "...",
      network: 3
    }
  }
}

network 3 from truffle networks:

Network: development (id: 3)
  Migrations: 0xfa79df82dce04e1a894df648f4f20af5a59f42f8
  WhaleNetworkV2: 0x93e21793323f9d3053b6a2bd2ab4234948aec210

in compiled contracts json file:

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

The code from which this error comes from:

if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
} else {
    // set the provider you want from Web3.providers
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}

console.log("provider", web3.currentProvider);

whaleNetworkV2 = contract(WhaleNetwork);
whaleNetworkV2.setProvider(web3.currentProvider);

whaleRewardsV2 = contract(WhaleRewards);
whaleRewardsV2.setProvider(web3.currentProvider);

let whaleNetworkContract;
let whaleRewardContract;

web3.eth.getAccounts((err, accounts) => {
    if (err != null) {
        console.log("There was an error fetching your accounts.");
        return;
    }

    if (accounts.length == 0) {
        console.log("Couldn't get any accounts! Make sure your Ethereum client is configured correctly.");
        return;
    }

    whaleRewardsV2.deployed().then((result) => {
        console.log(result);
    }).catch((error) => {
        console.log("whaleRewardsV2", error);
    });
});

The above code outputs:

provider HttpProvider {host: "http://localhost:8545", timeout: 0, connected: false} contracts.js:38 whaleRewardsV2 Error: WhaleRewardsV2 has not been deployed to detected network (network/artifact mismatch) at modules.js?hash=d495843d4bdb24e9ee23d52d143d36f9c62487b7:14057 at meteor.js?hash=cbcc712d51de4298c275e8dcf25c66c29914f19a:1167 at

Happens on both server and client.

1

I found my problem was that the metamask was on the wrong network

0

I was missing the from key in my truffle.js which then resulted in getting this message even though looking like they were correctly deployed.

0

In my case by local ports were blocked. I found out by trying to ping my local Ethereum server using:

ping 127.0.0.1:7545
ping: cannot resolve 127.0.0.1:7545: Unknown host

After changing the port to an approved local port it worked!

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.