I am facing error while calling/deploying my previous contract in new contract "SimpleStorage[] public simplestoragearray;" in line 4 of the code.
// SPDX-License-Identifier: MIT
pragma_solidity ^0.8.0;
import "./SimpleStorage.sol";
contract StorageFactory{
SimpleStorage[] public simplestoragearray;
function createsimplestoragecontract() public {
SimpleStorage simplestorage = new SimpleStorage();
simplestoragearray.push(simplestorage);
}
}
from solidity: DeclarationError: Identifier not found or not unique. --> contracts/test contracts/StorageFactory.sol:8:5: | 8 | SimpleStorage[] public simplestoragearray; | ^^^^^^^^^^^^^
Your contract is probably a differente name than your file.
Change the contract name so it is same as file name it should work.
It is standart practice to name contract file same as contract.
So inside SimpleStorage.sol it should be:
contract SimpleStorage { ... }