> For the complete documentation index, see [llms.txt](https://chihaolu.gitbook.io/all-in-one-solidity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chihaolu.gitbook.io/all-in-one-solidity/part-i-basic/chapter-5-han-shi-function.md).

# | Chapter 5 | 函式 Function

Function 又被翻譯為函數、方法、函式等，藉由呼叫（Call）以及 輸入參數（也可不輸入）後來達到某些行為，像是回傳（Returns，也可不回傳）或修改某些值。 當我們在一個函數的 parameter 前宣告 constant 時，此變數就不允許被賦值（除了初始化），也不佔用存儲槽。

#### 函式分類

呼叫函式通常有兩種情況，一種為Writing Transactions，也就是對區塊鏈上的狀態進行修改，這時我們呼叫函式這個動作也會成為一筆交易被記錄在鏈上。另一種為Reading Transactions，為閱讀鏈上的資料（閱讀鏈上交易），不會修改到鏈上的狀態，因此也是免費的。
