Skip to content

Instantly share code, notes, and snippets.

@MajdT51
Last active September 21, 2019 09:09
Show Gist options
  • Save MajdT51/86597fb9345799587435ee557c20eac5 to your computer and use it in GitHub Desktop.
Save MajdT51/86597fb9345799587435ee557c20eac5 to your computer and use it in GitHub Desktop.
modified SafeMath library example
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