1. Using Roles

  • 더 decentralized oracle을 위해, oracleowner의 access 권한을 분리할 필요가 있다. 따라서 owner address에서만 실행할 수 있는 add, remove와 같은 함수를 명시하기 위해 Roles를 써야 한다.
  • Roles는 다음과 같이 import한다
    • import "openzeppelin-solidity/contracts/access/Roles.sol";

2. Using Constructor to Set the Owner

  • constructor는 contract가 deploy 될 때, 단 한번만 실행된다.

3. Setting Up New Oracles

4. The Logical NOT Operator

  • !로 negation하기

5. Removing an Oracle

  • add도, remove_numOraclesrequire로 체크하면서 실행해야 한다.
    • 특히, 제거할 oracle이 없는데 remove를 실행하면 오류가 발생하기 때문에 더더욱 체크해야 한다.

6. Keeping Track of Responses

  • struct는 다음과 같이 정의한다.
    • struct myStruct {
        address callerAddress;
        uint256 keyNumber;
      }
      
  • 위에서 정의한 struct는 다음과 같이 선언한다
    • myStruct memory myInstance;
      myInstance = new myStruct(callerParam, numberParam);
      

7. Computing the ETH price

8. Computing the ETH price - cont’d

9. Using SafeMath

  • target.add(), target.sub()와 같은 SafeMath를 써야 overflow를 방지할 수 있다

10. Using SafeMath

11. Lesson Complete!