SafeERC20.sol 764 B

123456789101112131415161718192021222324
  1. pragma solidity ^0.4.18;
  2. import './ERC20Basic.sol';
  3. import './ERC20.sol';
  4. /**
  5. * @title SafeERC20
  6. * @dev Wrappers around ERC20 operations that throw on failure.
  7. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
  8. * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
  9. */
  10. library SafeERC20 {
  11. function safeTransfer(ERC20Basic token, address to, uint256 value) internal {
  12. assert(token.transfer(to, value));
  13. }
  14. function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal {
  15. assert(token.transferFrom(from, to, value));
  16. }
  17. function safeApprove(ERC20 token, address spender, uint256 value) internal {
  18. assert(token.approve(spender, value));
  19. }
  20. }