# Solidity Variables

Solidity is a statically typed language, which means that the type of each variable (state and local) needs to be specified.

There are 3 types of variables in Solidity

* **local**
    
    * declared inside a function
        
    * not stored on the blockchain
        
* **state**
    
    * declared outside a function
        
    * stored on the blockchain
        
* **global** (provides information about the blockchain)
    

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.3;

contract Variables {
    // State variables are stored on the blockchain.
    string public text = "Hello";
    uint public num = 123;

    function doSomething() public {
        // Local variables are not saved to the blockchain.
        uint i = 456;

        // Here are some global variables
        uint timestamp = block.timestamp; // Current block timestamp
        address sender = msg.sender; // address of the caller
    }
}
    
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1673523262672/8eb3ef8d-dac5-4bfb-91c9-f314e5930bd9.png align="center")
