SafeERC20

Git Source

Wrappers around ERC20 operations that throw on failure (when the token contract returns false). Tokens that return no value (and instead revert or throw on failure) are also supported, non-reverting calls are assumed to be successful. To use this library you can add a using SafeERC20 for IERC20; statement to your contract, which allows you to call the safe operations as token.safeTransfer(...), etc.

Functions

increaseAllowance

Increases the allowance granted to spender by the caller.

function increaseAllowance(IERC20 _token, address _spender, uint256 _addedValue) internal returns (bool);

Parameters

NameTypeDescription
_tokenIERC20Token to transfer.
_spenderaddressThe address which will spend the funds.
_addedValueuint256The amount of tokens to increase the allowance by.

safeTransfer

Calls transfer() without reverting.

function safeTransfer(IERC20 _token, address _to, uint256 _value) internal returns (bool);

Parameters

NameTypeDescription
_tokenIERC20Token to transfer.
_toaddressRecepient address.
_valueuint256Amount transferred.

Returns

NameTypeDescription
<none>boolWhether transfer succeeded or not.

safeTransferFrom

Calls transferFrom() without reverting.

function safeTransferFrom(IERC20 _token, address _from, address _to, uint256 _value) internal returns (bool);

Parameters

NameTypeDescription
_tokenIERC20Token to transfer.
_fromaddressSender address.
_toaddressRecepient address.
_valueuint256Amount transferred.

Returns

NameTypeDescription
<none>boolWhether transfer succeeded or not.