Skip to content

SimpleStorage #239

Answered by alymurtazamemon
cluck135 asked this question in Q&A
Jun 9, 2022 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

@cluck135

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 le…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@cluck135
Comment options

@alymurtazamemon
Comment options

Answer selected by cluck135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants