# Solidity 課程選讀
## 單純solidity課程(推薦)
### Learn Solidity basics
https://www.youtube.com/watch?v=sngKPYfUgkc&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=1
有程式基礎者建議部份跳過或快轉 (和其他程式語言非常類似)
#### 各章節內容
##### part 1:IDE 介紹(Remix),註釋寫法
##### part 2:基礎變數類型
##### part 3:local and global variable
變數權限
- public
- private
- internal
function
##### part 4 :Operator
- Arithmic
- Assigment
- Comparison
- Logical
- Condition
##### part 5: Unit (特殊的小數點系統(wei,gwei...),時間格式)
##### part 6: Logic
- if else
- loop
mapping, array, enum
##### part 7: struct, data location
- storage(直接接觸區塊鏈資料)
- memory(內存)
- calldata(unchangable)
function type
##### part 8: validate data
- require
- revert
- assert
##### part 9: More about contract
- modifier(for reuse)
- event(for listen)
- constructor
- inharitance
##### part 10: interface, pay for contract (recieve, fallback),send ether to user(transfer, send, call)
##### part 11: call other contract
##### part 12: solidity patterns
> 設計模式是為了解決程式語言的缺陷
參考資料:[Solidity Patterns(0.4.20)](https://fravoll.github.io/solidity-patterns/)
Behavior Patterns
- Guard Check
- State Machine
- Oracle
- Randomness
Security Patterns
- Access Restriction
- [Role Base example](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol)
- Checks Effects Interactions
- Security Ether Transfer
- prefer to use call (如果呼叫其他合約,用transfer,send可能會gas不足)
- Pull over Push
- 不要把錢匯到用戶錢包,而是幫他們存起來,讓他們自己來拿
- Emergency Stop
Upgradebility Pattern
- Proxy Delegate
- 用代理合約來和實際使用的合約交流,更新合約時把影響用戶使用的變化降到最低
- Eternal Storage
- 合約升級後,能保有其存儲的資料
Economic Patterns (節省gas fee)
- String Equality Comparison
- 比較string內容之前,先比較bytes的長度
- Tight Variable Packing
- 相同type的變數擺在一起 -> compile 方便, code 乾淨
- Memory Array Building
### 中文(台灣)
https://www.youtube.com/watch?v=z2FEikbDqoA&list=PLHmOMPRfmOxSJcrlwyandWYiuP9ZAMYoF
### 中文(中國)
https://www.youtube.com/watch?v=3sfknquTwXs&list=PLu3xEteHmEJDHVhCbJSl69dDGVS30WXGx&index=4
## 其他 Solidity 線上課程(較深且參雜其他主題)
### [cryptozombies](https://cryptozombies.io/)
Loom 創辦的 Solidity 學習網站,從入門教到zkSynk,包跨web3.js,部署合約,chainlink預言機
課程內容很全面,全英文,有點像答題網站,沒有自己做專案的感覺,適合有其他程式基礎的人快速上手
### [Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial](https://www.youtube.com/watch?v=M576WGiDBdQ&t=5647s)
freeCodeCamp 在 YT 上的免費教學影片,總長度16小時,從零基礎教到能自己搭建簡單的Dapp,講解得很詳細,全英文
有手把手操作,新手友善,且跟著影片可以學到除了程式以外的(編輯器,套件,部署)
課程包含
- solidity 合約
- js dapp網頁
- python dapp網頁
- NFTs
- Full Stack Defi
- Defi & Aave
- ERC20s, EIPs, and Token Standards
### [文檔閱讀](https://docs.soliditylang.org/en/v0.8.11/)
最硬的方法,能建構最全面的知識
### [tutorialspoint](https://www.tutorialspoint.com/solidity/solidity_events.htm)
w3schools 式的,沒有實做,純文件教學
也能當資料查詢的地方
### 鐵人賽
[Smart Contract 實戰教學(影片+文章)](https://www.youtube.com/watch?v=l6xmGVweJyk)
[Smart Contract 開發 - 使用 Solidity ](https://ithelp.ithome.com.tw/articles/10200395)
[區塊練起來-智能合約與DApp開發](https://ithelp.ithome.com.tw/articles/10216342)
依據主題有不同內容,30篇教學文章,寫的都蠻不錯的
全中文,而且如果有問題,應該都找的到作者提問
### [Hahao](https://hahow.in/courses/5b3cdd6ed03140001eebeadc/discussions/6002d1940cf6c97d3f21b725?item=5b40704fbc0cfe001ecd281c)
要錢:2850
### [encode club](https://www.encode.club/encode-bootcamp)
公鏈辦hackthon 和 bootcamp 的地方
和世界各地的人一起學習solidity,或各種技術
通常是好幾周的課程,每天會花可能1-2小時(或是每週),用Zoom上課
然後會出作業,課程結束有些有黑客松,有些有就業媒合
可以貼近實戰的學習,並且有老師和同學一起討論
缺點就是可能時間和進度不好調配(畢竟是配合別人)
## 補充資料
[怎麼學智能合約](https://www.youtube.com/watch?v=VNX6gSLvYX4)