Blockchain

Smart Contracts: Don’t Reinvent the Wheel

SafeMath

SafeMath is a library that ensures safe arithmetic operations by reverting the transaction if the bounds of an integer data type are exceeded.

SafeMath example.

The using statement indicates to the compiler that the contract is using functions defined in SafeMath for uint operations. Instead of using arithmetic operators (+, -, *, /, %), use the functions add(), sub(), mul(), div(), and mod().

Source: https://medium.com/better-programming/smart-contracts-dont-reinvent-the-wheel-63cee4370d19?source=rss——-8—————–cryptocurrency

Share on:
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •