wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.17k stars 283 forks source link

Handling Multiple Companion Networks for a Network #416

Open adi274 opened 1 year ago

adi274 commented 1 year ago

I want to deploy a pair of contracts on multiple L1-L2 networks, and for that I was using companionNetworks but when I am trying to define more than one companion network for a network, it reverts with

failed to get chainId, falling back on net_version...
Error HH110: Invalid JSON-RPC response received: invalid project id

Here is the code snippet from the hardhat config:

arbitrumGoerli: {
      chainId: 421613,
      url: "https://goerli-rollup.arbitrum.io/rpc   ",
      accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
      live: true,
      saveDeployments: true,
      tags: ["staging", "sender", "layer2"],
      companionNetworks: {
        receiver_gnosis: "chiado",
        receiver_eth: "goerli"
      },

There should be a way to handle multiple companionNetworks for a network.

wighawag commented 1 year ago

Unfortunately support for companion network is not very good. it is a feature that should be supported at a lower level in hardhat itself.

I am even considering removing it completely from hardhat-deploy

nataouze commented 1 year ago

@adi274 Are you sure your "chiado" and "goerli" networks are properly defined with a working endpoint? I Have been using multiple companion networks without issue here. @wighawag Please do not remove the feature until there is an equivalent support in hardhat :)

yohanelly95 commented 1 year ago

Is the feature currently supported? I get errors Error HH101 my hardhat config looks something like this

networks: {
    hardhat: {
      mining: {
        auto: false,
        interval: 10000,
      },
    },
    skale: {
      url: process.env.RPC_URL || "",
      accounts: { mnemonic: process.env.MNEMONIC || "test test test test test test test test test test test test" },
      chainId: 134534534,
      timeout: 300000,
    },
    mumbai: {
      url: process.env.RPC_URL || "",
      accounts: [process.env.DEPLOYER_KEY || ""],
      chainId: 80001,
      timeout: 300000,
      deploy: ["destination-deploy/"],
      companionNetworks: { nativeChain: "skale" },
    },
  },

and my deploy script is as follows:

  const { deployments, getNamedAccounts } = hre;
  const { deploy, get } = deployments;
  const { deployer } = await getNamedAccounts();
  const adminAddress = NATIVE_ADMIN;

  console.log("Deploying polygonM");
  await deploy("polygonM", {
    from: deployer,
    log: true,
    autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
    args: [adminAddress],
  });

  const polygonM = await get("polygonM");

  console.log(Contract Deployed Successfully {"polygonM" : "${polygonM.address}"});

  const skaleM = await hre.companionNetworks["nativeChain"].deployments.get("skaleM");

  console.log(hre.companionNetworks["nativeChain"], getNamedAccounts, bridgeContract);

does not seem to work atm, always throws error Error HH101: Hardhat was set to use chain id 134534534, but connected to a chain with id 80001 how do I connect to each respective chainId? @wighawag cc @nataouze since its worked for you, I am using a single companionNetwork

nataouze commented 1 year ago

It looks like you are using the same node url for both networks which could not work.

On Tue, 28 Feb 2023 at 14:51, Yohan Nelson @.***> wrote:

Is the feature currently supported? I get errors Error HH101 my hardhat config looks something like this networks: { hardhat: { mining: { auto: false, interval: 10000, }, }, skale: { url: process.env.RPC_URL || "", accounts: { mnemonic: process.env.MNEMONIC || "test test test test test test test test test test test test" }, chainId: 134534534, timeout: 300000, }, mumbai: { url: process.env.RPC_URL || "", accounts: [process.env.DEPLOYER_KEY || ""], chainId: 80001, timeout: 300000, deploy: ["destination-deploy/"], companionNetworks: { nativeChain: "skale" }, }, },

and my deploy script is as follows:

`const { deployments, getNamedAccounts } = hre; const { deploy, get } = deployments; const { deployer } = await getNamedAccounts(); const adminAddress = NATIVE_ADMIN;

console.log("Deploying polygonM"); await deploy("polygonM", { from: deployer, log: true, autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks args: [adminAddress], });

const polygonM = await get("polygonM");

console.log(Contract Deployed Successfully {"polygonM" : "${polygonM.address}"});

const skaleM = await hre.companionNetworks["nativeChain"].deployments.get("skaleM");

console.log(hre.companionNetworks["nativeChain"], getNamedAccounts, bridgeContract);`

does not seem to work atm, always throws error Error HH101: Hardhat was set to use chain id 134534534, but connected to a chain with id 80001 how do I connect to each respective chainId? @wighawag https://github.com/wighawag

— Reply to this email directly, view it on GitHub https://github.com/wighawag/hardhat-deploy/issues/416#issuecomment-1447621355, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7SSCMR2T5AIS24FTM5VIDWZWG4PANCNFSM6AAAAAAUL7NSCQ . You are receiving this because you commented.Message ID: @.***>

yohanelly95 commented 1 year ago

correct, figured this out forgot to update here. Thank you! @nataouze its resolved.