Last active
September 21, 2019 09:09
-
-
Save MajdT51/86597fb9345799587435ee557c20eac5 to your computer and use it in GitHub Desktop.
modified SafeMath library example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >= 0.4.25 < 0.6.0; | |
library SafeMath { | |
struct Balance { uint256 _balance; } | |
function add(Num storage self, uint256 amount) public { | |
uint256 newBalance = self._ balance + amount; | |
require(newBalance >= self._ balance, "addition overflow"); | |
self._ balance = newBalance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment