You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lessons/projects/1.mdx
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -284,6 +284,20 @@ contract WAGMI {
284
284
- **Struct:** Solidity allows users to create and define their own type in the form of structures. The structure is a group of different types even though it’s not possible to contain a member of its own type. The structure is a reference type variable which can contain both value types and reference types.
285
285
-**Mapping Type**: Stores the data in a key-value pair where a key can be any value types. It is like a hash table or dictionary as in any other programming language, where data can be retrieved by key.
286
286
287
+
### Visibility of State Variables
288
+
289
+
In Solidity , there are 3 types of visibility modifiers that a developer can use :
290
+
291
+
-**Public**: If a state variable visibility is marked as `public` then those variables can be used within the smart contract and can be accessed by other contracts as well.
292
+
293
+
-**Internal**: A state variable with a `internal` visibility can only be accessed within the smart contract and its subclasses. It can *NOT* be accessed externally.
294
+
295
+
-**Private**: When a state variable visibility is marked as `private` then it means , that it is only ment to be used within the defined smart contract . No subclasses and no external function should access a variable with a `private` visibility.
296
+
297
+
#### Which visibility should I use ?
298
+
299
+
A simple answer to this is , start with giving every variable a `private` visibility then as you move further in contract developement modify variables to `internal` visibility as a next step of modification. Try to use `public` visibility as little as possible in order to be gas efficient and making less vulnerabilities in the smart contract.
300
+
287
301
</ContentSideDrawer>
288
302
289
303
## Creating Functions
@@ -687,10 +701,9 @@ you see the magical spell that is being cast here?
687
701

688
702
689
703
Before you go ahead and tell us: **what your future in web3 is,** have a check
690
-
on what you didn’t know a little while ago, and what you know now! *
704
+
on what you didn’t know a little while ago, and what you know now! \*
691
705
692
-
Apart from a user wallet, what else uses a blockchain (Ethereum)
693
-
address?
706
+
Apart from a user wallet, what else uses a blockchain (Ethereum) address?
694
707
695
708
How many parameters can we have in an event?
696
709
@@ -700,8 +713,7 @@ Ethereum uses something for transaction fees. What’s it called?
700
713
701
714
Where do the values for event parameters get stored?
702
715
703
-
What is the use of the **pragma solidity** statement in our smart
704
-
contract?
716
+
What is the use of the **pragma solidity** statement in our smart contract?
705
717
706
718
Do state variables stay permanently on the blockchain?
707
719
@@ -710,4 +722,4 @@ Can a view function modify the state of the blockchain?
710
722
What can we use a smart contract for?
711
723
712
724
**Now, go to the community in Discord to share your new Open Sourcerer
0 commit comments