Below is the contract which imports another contract
pragma solidity ^0.8.7;
import "./SimpleStorage.sol";
contract StorageFactory {
SimpleStorage[] public simpleStorageArray;
function createSimpleStorageContract() public {
SimpleStorage simpleStorage = new SimpleStorage();
simpleStorageArray.push(simpleStorage);
}
}
Now after using function createSimpleStorageContract()
and trying to fetch elements of array , we are seeing
SimpleStorage
is another contract which I wrote and then imported it. Now simpleStorageArray
is an array of type SimpleStorage
. However what I am not able to understand which I try to fetch any value by providing index number in remix , it returns me the address. In every element it should store a new instance of contract why is it storing addresses. Can anyone please explain if array is of SimpleStorage contract type then why it stores & returns address when given index number ?