Problem with the error Error: Cannot create instance of Whitelist; no code at address 0x6198149b79AFE8114dc07b46A01d94a6af304ED9

How do I have to setup truffle so that I can run a test which includes data from a mainnet contract while the test itself runs on the development chain?


contract("WhitelistAdvanced Tests", async accounts => {
  var whitelist;

  before(async () => {
    whitelist = await Whitelist.at("0x6198149b79AFE8114dc07b46A01d94a6af304ED9");


networks: {
    development: {
      host: "",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
    mainnet: {
      provider: () => new HDWalletProvider(mnemonic, "https://mainnet.infura.io/v3/" + infuraKey, 0),
      network_id: 1,       // Mainnet's id
      gas: 9975000,        // Block gas


const Whitelist = artifacts.require("Whitelist");
const WhitelistAdvanced = artifacts.require("WhitelistAdvanced");

module.exports = function (deployer, network) {
  if (network === 'mainnet') {
  } else {
  • What is your network configuration (in file truffle.js or truffle-config.js)? – goodvibration Sep 24 '19 at 16:07
  • BTW, the contract function in Truffle tests takes a regular function, not an async function. – goodvibration Sep 24 '19 at 16:08
  • We also need to see migration script to see how WhiteList is deployed. Because, I am assuming from the error message, there is contract deployed at this address and this is what truffle is saying. – Rob Magier Sep 24 '19 at 19:53
  • I mean. There is no contract deployed at this address. – Rob Magier Sep 24 '19 at 20:00
  • @RobMagier updated the question with these files. To clarify, the contract I try to get information from is on the Mainnet. You can check the address, it exists. Put I wanna test on the local chain. – Senju Oct 2 '19 at 11:33

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.