There are more than one version of safeMath
on openZeppelin
. On master
branch, the URL is:
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol
Besides master
branch, there are quite a few other version available. Here is version 3.0.0:
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.0.0/contracts/math/SafeMath.sol
If someone wants to use the safeMath
in her/his smart contact development, which version shall be imported? Shall import master
branch at any time?
master
branch:
pragma "^0.7.0"
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol"
contract myContract() {
//do something
}
It depends on the solidity version you are using in your main contract. For contract using versions >=0.8.0 the use of safeMath read this. For contract written in older version (say) 0.6.0 the use of the latest safeMath library written for version 0.8.0 will not be compatible. In conclusion, try using the version of safeMath that is the same with the version of your main contract.