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