Some contents of this article are based on Cryptozombies’s source code, based on GPL-3.0

Lesson 3

Chapter 1: Immutability of Contracts

  • after it is deployed, it is immutable
    • it enhances security of blockchain contracts

Chapter 2: Ownable Contracts

  • Ownable gives special privileges for the contract owner

Chapter 3: onlyOwner Function Modifier

  • ‘DApp is on Ethereum’ does not automatically mean it’s decentralized
  • _;: go back to modifier caller

Chapter 4: Gas

  • Execution costs ‘Gas’: So optimization matters
  • Ethereum을 하나의 컴퓨터로 볼 때, 모든 노드가 computation을 함으로써 immutable, decentralized를 달성
    • 이런 건전한 생태계에, clog up하는 것을 막기 위한 노력이 필요함
    • infinite loop, hog all the network resources 등을 방지하는 차원
    • 그래서 모든 tx를 free로 만들지 않고 값어치를 매겼다
  • uint a;
    uint32 b;
    uint32 c;
    
    uint32 b;
    uint a;
    uint32 c;
    
  • 위의 코드가 아래의 코드보다 cost-efficient하다.
    • identical data type을 물리적으로 붙여놓아야 cost가 적게 든다. 이는 저장 공간을 덜 사용하기 때문이다.

Chapter 5: Time Units

  • Solidity도 seconds,minutes부터 years까지 있다.

Chapter 6: Zombie Cooldowns

  • returns (dataType)

Chapter 7: Public Functions & Security

  • internal,external,private,public 잘 구분하기

Chapter 8: More on Function Modifiers

Chapter 9: Zombie Modifiers

  • require 안에는 명제가 들어가야 한다!
    • 참이어야 이하를 수행하니까!

Chapter 10: Saving Gas With ‘View’ Functions

  • view function doesn’t cost gas
    • it just query Ethereum node, and does not create a tx.

Chapter 11: Storage is Expensive

  • using storage is kind of expensive operation in Solidity

Chapter 12: For loops

Chapter 13: Wrap-up