[Solidity] 230215 study
Some contents of this article are based on Cryptozombies’s source code, based on GPL-3.0
Lesson 1
Chapter 1: Lesson Overview
Chapter 2: Contracts
- Solidity is encapsulated in contracts
- All solidity source should start with ‘version pragma’
Chapter 3: State Variables & Integers
- uint is normal, basic data type
Chapter 4: Math Operations
Chapter 5: Structs
Chapter 6: Arrays
dataType[] pub/prv arrayName
Chapter 7: Function Declarations
- storing in memory
- by value, by reference
Chapter 8: Working With Structs and Arrays
- arrayName.push(proper_parameters)
Chapter 9: Pritvate / Public functions
- Function is set as public, by default
- however, it is good pratice to mark it as private
- we should change it into public, when it needed
- private function name starts with ‘_‘(underscore)
Chapter 10: More on Functions
- view / pure
- function mark 할 때,
return이 아니라returns다!
Chatper 11: Keccak256 and Typecasting
- Keccak256: a version of SHA256
- Solidity 공식 문서에서 말하고 있는 abi.encodePacked()의 기능
- abi: (contract)Application Binary Ineteface
- abi.encodePacked(): non-standard, under 32byte는 not padding, array elements는 padded, still encoded in-place
Chapter 12: Putting it together
- '_'을 넣어서 선언한 함수는 calling 할 때도 '_' 붙일 것!
나는 붙일지 말지 헷갈렸다
Chapter 13: Events
- event는 emit으로 fire –> front-end에게 전달해야 한다.
Chapter 14: Web3.js
- We need to write a JavaScript frontend that interacts with the contract.