0

I'm trying to use a interface on remix IDE and my only issue is that I have to copy and paste the contract's address. Is there a way that I can point it automatically?

ty.

1 Answers1

0

In Remix IDE, you need to copy and paste the newly deployed address manually.

With frameworks, such as Hardhat, you can retrieve the address of the deployed contract in the code and then pass it to the other contract.

In the example below, we're passing the address of First instance to Second's constructor, using the Hardhat JS framework.

const firstFactory = await ethers.getContractFactory("First");
const first = await firstFactory.deploy();
await first.deployed();

const secondFactory = await ethers.getContractFactory("Second");
const second = await secondFactory.deploy(first.address);
await second.deployed();
pragma solidity ^0.8;

contract First {}

contract Second {
    constructor(address firstAddress) {}
}
Petr Hejda
  • 40,554
  • 8
  • 72
  • 100