Files
openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol
2018-07-31 13:06:53 -03:00

33 lines
814 B
Solidity

pragma solidity ^0.4.24;
import "./ERC20Basic.sol";
import "./ERC20.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(ERC20Basic _token, address _to, uint256 _value) internal {
require(_token.transfer(_to, _value));
}
function safeTransferFrom(
ERC20 _token,
address _from,
address _to,
uint256 _value
)
internal
{
require(_token.transferFrom(_from, _to, _value));
}
function safeApprove(ERC20 _token, address _spender, uint256 _value) internal {
require(_token.approve(_spender, _value));
}
}