New contracts visibility

95 views Asked by At

first of all, excuse me because I am starting to learn Solidity programming, and this question is surely trivial for most of you, but I haven't found any answer yet.

When I create a simple smart contract from within another one (using "new"), and I try to check the new contract visibility, I cannot find it on etherscan (Rinkeby), even though I can interact with it from within Remix IDE. Is there any reason for that?

Thank you very much in advance!!

3

There are 3 answers

1
Or Duan On

First, how do you know which address the new contract has? You can try to log it via event emitting and Remix will show it on the console.

Secondly, on which network are you deploying your contract? By default Remix use an EVM VM that some mimic a fake network, it is not a public test net, just something that runs locally in your browser, meaning, you can not see in etherscan.

To achieve this, you have to choose "injected web3" in the environment dropdown during the deployment process.

enter image description here

There are a lot of gotchas but here is a good guide on how to connect your metamastk testnet.

0
Tanjin Alam On

when you create Contract that Creates other Contracts,It doesn't create or what you are trying to say that it doesn't deploying any new contract on Rinkeby.

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
contract Account {
    address public owner; 
    constructor(address _owner) {
        owner = _owner; 
    }
}
contract AccountFactory{
    function createAccount(address _owner) public {
        Account account = new Account(_owner);
    }
}

When you are deploying the written smart contract both Account and AccountFactory will be deployed you will be able to find it on (Rinkeby) Therefore each time you hit the public createAccount function it's just making an transaction on with interact with the deployed Account smart contract which will definitely not create Account smart contract again for each function call.

Have a look HERE

0
Jose Maria On

Thank you all!

For example, if this piece of code

    SimpleStorage[] public simpleStorageArray; 

    function createSimpleStorageContract() public {
    SimpleStorage simpleStorage = new SimpleStorage();
    simpleStorageArray.push(simpleStorage);

    }  
       

is suposed to "deploy" a new instance of a contract (storing their addresses in an array), each time I call the function, so we can interact with to store or retrieve values, or whatever, my question came because I figured out that the address of the new "deployed" contract (contained in simpleStorageArray) should be found in Etherscan, but it actually does not.