-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
committed
Jul 28, 2022
1 parent
04fdf0a
commit d051048
Showing
1 changed file
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
import Callout from 'nextra-theme-docs/callout' | ||
# State variables in Solidity | ||
|
||
# State variables | ||
- State variables are permanent and stored on the blockchain in contract storage. | ||
- Declared outside of a function and stored on the blockchain | ||
- Stored on the blockchain in the order of declaration | ||
|
||
```jsx | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.13; | ||
|
||
contract Variables { | ||
// State variables will be saved on the blockchain. | ||
string public tokenName = "TokenName"; | ||
uint public counter = 1; | ||
|
||
function sampleFunction() public { | ||
// Local variables are not saved on the blockchain. | ||
uint i = 1; | ||
|
||
// Here are some global variables | ||
uint timestamp = block.timestamp; // Current block timestamp | ||
address sender = msg.sender; // address of the caller | ||
} | ||
} | ||
``` |