0

I am trying to deploy the same contract code to create multiple instance:

const contract = require('truffle-contract')

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

module.exports = function(deployer) {

  contract("Greeter3", async (accounts) => {
    it("should be initialized twice", async () => {
      let instance1 = await Greeter3.new();
      let instance2 = await Greeter3.new();
      assert.notEqual(instance1.address, instance2.address);

      deployer.deploy(instance1);
      deployer.deploy(instance2);
    });
  });

};

No error message is returned, but the deployment fails:

6_multi.js
==========

   > Saving migration to chain.
   -------------------------------------
   > Total cost:                   0 ETH

What does this response mean?

  • This looks like a confused mixture of a truffle test script and a truffle migration script. You should start by fixing that, to begin with. A truffle migration script doesn't need to declare neither contract(...) nor it(...). You might want to read this truffle-migration tutorial first. – goodvibration May 4 at 6:49
  • The tutorial does not specify how to deploy multiple instances of the same contract. How would that be done? – Burrough May 4 at 6:58
  • I'm not entirely sure, but shouldn't you be awaiting deployer.deploy()? – Henk May 4 at 7:11
  • See this answer of mine, of am example script which you can use, I believe, for your purpose. – goodvibration May 4 at 15:42

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.