I have a contract called Marketplace which gets deployed as a standalone contract with ethers.js. This contract instantiates another contract called NFT, therefore it's supposedly deployed implicitly by ethers.js. Here's how it's instanciated:
import "./NFT.sol";
contract Marketplace {
NFT nft = new NFT();
...
As mentioned, I only deploy Marketplace, and this is how I do it in the deploy.js script:
const Marketplace = await ethers.getContractFactory("Marketplace");
const marketplace = await Marketplace.deploy();
I read that in Solidity when a contract inherits another contract, the code from both gets merged into one contract, but does this also happen when a contract instantiates another contract, like in my case above?
Initially I thought so, but looking around etherscan I found out that two contract addresses were deployed, and I wasn't expecting to have two standalone contracts but one, since I am explicitly only deploying Marketplace.
Am I supposed to change Hardhat's configuration or do something else in order to achieve that both Marketplace and NFT are deployed under one contract address, or that's not how the compiler works?