> For the complete documentation index, see [llms.txt](https://calnix.gitbook.io/eth-dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calnix.gitbook.io/eth-dev/learning-solidity/module-1/functions.md).

# Functions

## **Function Structure**

![Example](/files/APKskEcBIZgkljskKIbw)

* `public` -> visibility declaration&#x20;
* `view` -> Indicates function behavior
* `returns` -> Data type that the function returns (optional)

```solidity
function functionName(parameter1, parameter2) {public|private|internal|external} 
[pure|view|payable] [(modifiers)] [returns (<return types>)]
```

## Function Visibility

#### A function declarations only impose scope and do nothing for security

![](/files/1tH3HwpDgGgHl5p6UrkZ)

### Simply put:

**public ->** functions can be called both internally and externally&#x20;

**external ->** only external calls; cannot be accessed internally

**internal ->** only this contract and contracts deriving from it can access

**private ->** functions can only be called from within the contract

{% hint style="danger" %}
Cannot create a function with the same name as a storage variable. Will conflict with getter function.
{% endhint %}
