0

I'm trying to access a smart contract in my local dev environment, but it doesn't appear to be deploying fully. In summary, I get what seems to be a successful migration, however, I am not able to access the contract using web3.js/truffle-contract.js, and I get the following response in truffle console (MyToken.deployed() does return the expected contract info):

truffle(development)> MyTokenCrowdsale.deployed();
Uncaught:
Error: MyTokenCrowdsale has not been deployed to detected network (network/artifact mismatch)
truffle(development)>

All tests against the 'Crowdale' contract pass

The output from truffle migrate is:

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0xa85fc78b1b630c0234376fcf3cb27f47c10cda7c0c35c517518b017edaa31b97
  Migrations: 0x417007b8fcd1a9c970f03756857ff27ebb61135f
Saving artifacts...
Running migration: 2_deploy_crowdsale.js
  Deploying MyToken...
  ... 0x7d5c3d4d6d60139001eab8621cec5b98cf893a44786abb96e901fe942bcdea47
  MyToken: 0xd4bd879faa59c4b5b3af1e9074d71ab407cb19da
Saving artifacts...
  Deploying MyTokenCrowdsale...
  ... 0xe469c8fbd19895674074d6fbeb2b3bcf1d2adaefc07aabf74254aa99678f275e
  MyTokenCrowdsale: 0x35b66ed95a88157ddaf85c20a1d3d189c5cdafa3

I'm running a local dev node with ganache-cli. The network config is:

    development: {
     host: "127.0.0.1",     // Localhost (default: none)
     port: 8545,            // Standard Ethereum port (default: none)
     network_id: "*",       // Any network (default: none)
    },
    ganache: {
      post: 'localhost',
      port: 8545,
      networkd_id: '*'
    },

Thanks!

2
  • I tried this on rinkeby network and get the same problem. Its odd that the test cases successfully deploy the contracts and run the tests, but migration doesn't.
    – broadbear
    Jul 30, 2021 at 17:47
  • I'm just noticing this, but the MyToken.json build artifact has information in the networks section, (looks like three transaction entries), but the MyTokenCrowdsale.json build artefact does not. Could this be part of the issue? Why would one contract be populating this section but the other is not?
    – broadbear
    Jul 30, 2021 at 17:55

1 Answer 1

0

The problem seems to be related to a bug report filed on github: https://github.com/trufflesuite/truffle/issues/573. I converted the async/await syntax to a promise chain and both contracts appear to be deploying successfully now. Ex:

Convert:

await deployer.deploy(A);
await deployer.deploy(B);

To:

deployer.deploy(A).then(function() {
  deployer.deploy(B, A.address);
});

Your Answer

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

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