iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 18
1

因為今天要搭飛機離開台灣,因此在吵雜的機場裡面錄影的,效果可能很差QQ
接下來幾天因為要到日本去,如果在日本的網路因故悲劇,那就只能中斷了(._.)

本日合約:

pragma solidity ^0.4.25;

library SafeMath {

  function mul(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a * b;
    require(c / a == b);

    return c;
  }

  function div(uint256 a, uint256 b) internal pure returns (uint256) {
    require(b > 0); // Solidity only automatically asserts when dividing by 0
    uint256 c = a / b;
    
    return c;
  }

  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    require(b <= a); // underflow 
    uint256 c = a - b;

    return c;
  }

  function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    require(c >= a); // overflow

    return c;
  }

  function mod(uint256 a, uint256 b) internal pure returns (uint256) {
    require(b != 0);
    return a % b;
  }
}

contract Main {
    function test() public pure returns (uint256) {
        uint256 a = 100;
        uint256 b = 10;
        return SafeMath.add(a, b);
    }
}

本日影片:
https://youtu.be/9A0vAqjUFe0

Smart Contract 實戰教學播放清單:
https://www.youtube.com/playlist?list=PLHmOMPRfmOxSJcrlwyandWYiuP9ZAMYoF


上一篇
Library
下一篇
Import & Using for
系列文
Smart Contract 實戰教學30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言