# 5: State Variable

State variables in Solidity are variables that are inside a smart contract. They are stored in the blockchain and their values are persistent and publicly accessible. State variables can be of any data type, such as strings, booleans, integers, and arrays. State variables are typically used to store information about a contract, such as user balances, contract owners, or the current status of a contract.

A state variable can be declared in a smart contract like so:

```solidity
contract MyContract {    
    uint public balance; // Declares a state variable
}
```

State variables can also be declared as private, which means that only functions within the same contract can access them.

```solidity
contract MyContract {    
    uint private balance; // Declares a private state variable
}
```

*That's it for the lesson 5! In the next lesson, Local Variable*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://solstep.gitbook.io/solidity-steps/step-1/5-state-variable.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
