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.

4 Answers 4

3

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

2
  • Same as me. Good answer! Jun 2, 2019 at 10:53
  • haha yeah pretty obvious one but i had the same issue time and time again too :) Also another common issue is, you see mismatching info when testing from two clients, this is due to the time it takes for blocks to mine so both clients can see the same data, that one was confusing initially too.
    – sed
    Jun 27, 2020 at 13:21
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.

1
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!

0

I added a localhost to Metamask and made the port 7545. And it worked. Then I copied the keys from Ganache to create account and it added the Eth. Also increase your gas fees

Your Answer

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

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