1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- pragma solidity ^0.4.24;
- import "./ERC20.sol";
- import "./IERC20.sol";
- /**
- * @title SafeERC20
- * @dev Wrappers around ERC20 operations that throw on failure.
- * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
- * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
- */
- library SafeERC20 {
- function safeTransfer(
- IERC20 _token,
- address _to,
- uint256 _value
- )
- internal
- {
- require(_token.transfer(_to, _value));
- }
- function safeTransferFrom(
- IERC20 _token,
- address _from,
- address _to,
- uint256 _value
- )
- internal
- {
- require(_token.transferFrom(_from, _to, _value));
- }
- function safeApprove(
- IERC20 _token,
- address _spender,
- uint256 _value
- )
- internal
- {
- require(_token.approve(_spender, _value));
- }
- }
|