PatrickAlphaC / storage-factory-fcc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type Error

BlairWhitaker opened this issue · comments

//could someone guide me as to why this code won't compile? it has an issue on line 38 but I can't figure why.

TypeError: Name has to refer to a struct, enum or contract.
--> StorageFactory.sol:38:5:|
38 | SimpleStorage public SimpleStorage;
| ^^^^^^^^^^^^
thanks

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract SimpleStorage {

    // This get initialized to zero!
    // <- This means that this section is a comment!
    uint256 favoriteNumber;
   
   mapping(string => uint256) public nameToFavoriteNumber;

   struct People {
       uint256 favoriteNumber;
       string name;
   }

   //unit256[] public favoriteNumberList;
   People[] public people;

    function store(uint256 _favoriteNumber) public {
        favoriteNumber = _favoriteNumber;
    }

    // view, pure
    function retrieve() public view returns(uint256){
        return favoriteNumber;
    }

    // calldata, memory, storrage
    function addPerson(string memory _name, uint256 _favoriteNumber) public {
        people.push(People(_favoriteNumber, _name));
        nameToFavoriteNumber[_name] = _favoriteNumber;
    }

}

contract StorageFactory {
    SimpleStorage public SimpleStorage;

    function createSimpleStorageContract() public {
        SimpleStorage = new SimpleStorage();
    }

}

You have some capitalization issues:

It should be:

contract StorageFactory {
    SimpleStorage public simpleStorage;

    function createSimpleStorageContract() public {
        simpleStorage = new SimpleStorage();
    }

}

Thankyou