TransferHelper
Last updated
Last updated
This library provides helper methods for interacting with ERC20 tokens and sending ETH. These methods ensure safe and reliable token transfers by checking the success of the transfer operations.
safeApprove
Safely approves the specified to
address to spend the specified value
amount of tokens from the token
contract. It uses the approve
function of the ERC20 token.
Name | Type | Description |
---|---|---|
safeTransfer
Safely transfers the specified value
amount of tokens from the caller's address to the to
address. It uses the transfer
function of the ERC20 token.
Name | Type | Description |
---|---|---|
safeTransferFrom
Safely transfers the specified value
amount of tokens from the from
address to the to
address. It uses the transferFrom
function of the ERC20 token.
safeTransferETH
Safely sends the specified value
amount of Ether to the to
address.
decimals
Retrieves the number of decimal places used by the specified ERC20 token
contract.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
token
address
The address of the ERC20 token contract.
to
address
The address to approve for spending the tokens.
value
uint
The amount of tokens to approve.
token
address
The address of the ERC20 token contract.
to
address
The address to which the tokens should be transferred.
value
uint
The amount of tokens to transfer.
token
address
The address of the ERC20 token contract.
from
address
The address from which the tokens should be transferred.
to
address
The address to which the tokens should be transferred.
value
uint
The amount of tokens to transfer.
to
address
The address to which the Ether should be sent.
value
uint
The amount of Ether to send.
token
address
The address of the ERC20 token contract.
decimals
uint8
The number of decimal places used by the token.