# 3. 函数类型-Solidity入门笔记

By [markchern](https://paragraph.com/@markchern) · 2022-11-08

---

函数形式

    function name(<parameter types>) {public|private|internal|external} [pure|view|payable] [returns (<return types>)]
    

1.function，声明关键字

2.name，函数名

3.圆括号内写函数参数，可选。

4.花括号内是函数的可见性说明符

4.1public，内外部可见

4.2private 仅内部可访问，继承不可用

4.3internal 仅内部可访问，继承可用

4.4external 仅外部可访问

5.函数权限符

5.1pure 不可读不可写

5.2view 可读不可写

5.3payable 可支付

使用payable可以构造给合约支付ETH的

pure和view不消耗gas

6 返回值

返回的参数列表

---

*Originally published on [markchern](https://paragraph.com/@markchern/3-solidity)*
