wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.21k stars 298 forks source link

Multiple contract deployments overrides data #322

Open knerushkin-rumblefish opened 2 years ago

knerushkin-rumblefish commented 2 years ago

Describe the bug When I'm deploying multiple ERC20, after it I have deployment data only for the latest one being deployed

deploying "ERC20PresetMinterPauser" (tx: 0x7bdb49486025e1966e9e35b96f3eeddea529f9d54d264a05eff9fb00c3a4ab7f)...: deployed at 0xA06cF71f8f280D2B89156bbCb70Ff3bD765fb50D with 329911 gas
deploying "ERC20PresetMinterPauser" (tx: 0xc735f76e16023d50770b38a8f82d309e9911524b2894c622bda217ee93435d03)...: deployed at 0xFFDA9c68179eb87BD156BE28386b417F38931853 with 329911 gas
deploying "ERC20PresetMinterPauser" (tx: 0xfdb433bda531932fba2b98d3c5e612df8d9acf9dffd0a6a768ca452c00b6da9f)...: deployed at 0x348046e9BA013F1D52f877202b7838ed3c852Bd7 with 329911 gas
{
  "address": "0x348046e9BA013F1D52f877202b7838ed3c852Bd7",
  "abi": [
    {
      "inputs": [
        {
          "internalType": "string",
          "name": "name",
          "type": "string"
        },
        {
          "internalType": "string",
          "name": "symbol",
          "type": "string"
...

To Reproduce Steps to reproduce the behavior:

  1. deploye multiple ERC20

Expected behavior Get post-deployment data containing address informations about all deployed ERC20 Is there any way to do that?

versions

asmitadhungana commented 2 years ago

You can initialize different identifiers for different instances of the same contract to resolve the overriding issue. Somewhat like:

const tokens = ["token1", "token2", token3"]; // identifiers of different ERC20PresetMinterPauser instances
let _tokens = [];
 for (let i = 0; i < 3; i++) {
      log(`Deploying ${tokens[i].toUpperCase()} contract ...`);
      _tokens[i] = await deploy(tokens[i], {
          from: deployer,
          contract: "ERC20PresetMinterPauser", // This is where you initialize the contract to be deployed
          args: [`${tokens[i]} token`, tokens[i].toUpperCase(), 1000000],
          log: true
      });