SimpleStorage #239
-
Hello! :) The only thing I can think is that when you write it as `// SPDX-License-Identifier: MIT import "./SimpleStorage.sol"; contract StorageFactory {
}` |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This line is called an instance of the contract. SimpleStorage public simpleStorage; it is similar to how we define variables in javascript let simpleStorage; And this line initializes it with SimpleStorage contract when we will press the createSimpleStorageContract button. function createSimpleStorageContract() public {
simpleStorage = new SimpleStorage();
} similar to javascript simpleStorage = //value according to data type. Now come to your question why cannot we leave it as: SimpleStorage public simpleStorage; So the answer is, if we will not initialize it then we cannot interact with the SimpleStorage contract with the help of it. hope it clears the question, please let me know if you have any queries. |
Beta Was this translation helpful? Give feedback.
@cluck135
This line is called an instance of the contract.
it is similar to how we define variables in javascript
And this line initializes it with SimpleStorage contract when we will press the createSimpleStorageContract button.
similar to javascript
Now come to your question why cannot we leave it as:
So the answer is, if we will not initialize it then we cannot interact with the SimpleStorage contract with the help of it.
hope it clears the question, please le…