Lesson 2: "SimpleStorage" vs "simpleStorage" #5447
-
My understanding is that "SimpleStorage" is the type of variable while "simpleStorage" is the name we assigned to the variable. However, I think my thinking is flawed since when I researched the types of solidity variables none of them were "SimpleStorage". Is "SimpleStorage" syntax of some kind? Why does it seem like we use that phrase specifically as an identifier? Here is the code below: contract StorageFactorty {
SimpleStorage[] public simpleStorageArray;
function createSimpleStorageContract() public {
//in order to let the storage factory know what the Simple Storage code looks like I will copy and paste the code from the other file
SimpleStorage simpleStorage = new SimpleStorage();
simpleStorageArray.push(simpleStorage);
}
function sfStore(uint256 _simpleStorageIndex, uint256 _simpleStorageNumber) public
{
//To interact witj a contract you will need its Adrees and its ABI - Application Binary Interface
SimpleStorage simpleStorage = simpleStorageArray[_simpleStorageIndex];
simpleStorage.store(_simpleStorageNumber);
}
function sfGet (uint _simpleStorageIndex) public view returns (uint256){
SimpleStorage simpleStorage = simpleStorageArray[_simpleStorageIndex];
return simpleStorage.retrieve();
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hello @oceanwillo In this case our |
Beta Was this translation helpful? Give feedback.
-
@oceanwillo I think you didn't see this type while searching Contract Types in Solidity |
Beta Was this translation helpful? Give feedback.
@oceanwillo Yes, it is working for objects like contracts or even structs etc.
Some example of struct object: