add safe ERC20 helpers
This commit is contained in:
22
contracts/token/SafeERC20.sol
Normal file
22
contracts/token/SafeERC20.sol
Normal file
@ -0,0 +1,22 @@
|
||||
pragma solidity ^0.4.11;
|
||||
|
||||
import './ERC20Basic.sol';
|
||||
import './ERC20.sol';
|
||||
|
||||
/**
|
||||
* @title SafeERC20
|
||||
* @dev Wrappers around ERC20 operations that throw on failure.
|
||||
*/
|
||||
library SafeERC20 {
|
||||
function safeTransfer(ERC20Basic token, address to, uint256 value) internal {
|
||||
assert(token.transfer(to, value));
|
||||
}
|
||||
|
||||
function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal {
|
||||
assert(token.transferFrom(from, to, value));
|
||||
}
|
||||
|
||||
function safeApprove(ERC20 token, address spender, uint256 value) internal {
|
||||
assert(token.approve(spender, value));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user