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));
- }
- }
|