prysm-pulse/contracts/validator-registration-contract/SafeMath.sol
2019-01-01 08:10:56 -08:00

21 lines
645 B
Solidity

pragma solidity ^0.5.1;
library SafeMath {
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "The second parameter can not be greater than first one.");
uint256 c = a - b;
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "The first parametert can not be greater than the sum of two parameters");
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "The second parameter can not be zero");
return a % b;
}
}