โGas Saving Technique 12: SafeMath no longer needed
Introduction
Impact & Details
How to Remove SafeMath for Gas Savings
solidityCopy code// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
contract MyContract {
using SafeMath for uint256;
function add(uint256 a, uint256 b) public pure returns (uint256) {
return a.add(b);
}
}Recommended Mitigation Steps
Conclusion
PreviousGas Saving Technique 11: > 0 is less efficient than != 0 for unsigned integersNextGas Saving Technique 13: variables default to 0
Last updated