SafeERC20.sol 814 B

1234567891011121314151617181920212223242526272829303132
  1. pragma solidity ^0.4.24;
  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. require(_token.transfer(_to, _value));
  13. }
  14. function safeTransferFrom(
  15. ERC20 _token,
  16. address _from,
  17. address _to,
  18. uint256 _value
  19. )
  20. internal
  21. {
  22. require(_token.transferFrom(_from, _to, _value));
  23. }
  24. function safeApprove(ERC20 _token, address _spender, uint256 _value) internal {
  25. require(_token.approve(_spender, _value));
  26. }
  27. }