ERC1363Upgradeable
Inherits: Initializable, ERC20Upgradeable, ERC165Upgradeable, IERC1363
Extension of {ERC20} tokens that adds support for code execution after transfers and approvals on recipient contracts. Calls after transfers are enabled through the {ERC1363-transferAndCall} and {ERC1363-transferFromAndCall} methods while calls after approvals can be made with {ERC1363-approveAndCall} Available since v5.1.
Functions
__ERC1363_init
function __ERC1363_init() internal onlyInitializing;
__ERC1363_init_unchained
function __ERC1363_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, IERC165)
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
transferAndCall
*Moves a value
amount of tokens from the caller's account to to
and then calls IERC1363Receiver-onTransferReceived on to
. Returns a flag that indicates
if the call succeeded.
Requirements:
- The target has code (i.e. is a contract).
- The target
to
must implement the {IERC1363Receiver} interface. - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
- The internal {transfer} must succeed (returned
true
).*
function transferAndCall(address to, uint256 value) public returns (bool);
transferAndCall
Variant of transferAndCall that accepts an additional data
parameter with
no specified format.
function transferAndCall(address to, uint256 value, bytes memory data) public virtual returns (bool);
transferFromAndCall
*Moves a value
amount of tokens from from
to to
using the allowance mechanism
and then calls IERC1363Receiver-onTransferReceived on to
. Returns a flag that indicates
if the call succeeded.
Requirements:
- The target has code (i.e. is a contract).
- The target
to
must implement the {IERC1363Receiver} interface. - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
- The internal {transferFrom} must succeed (returned
true
).*
function transferFromAndCall(address from, address to, uint256 value) public returns (bool);
transferFromAndCall
Variant of transferFromAndCall that accepts an additional data
parameter with
no specified format.
function transferFromAndCall(address from, address to, uint256 value, bytes memory data)
public
virtual
returns (bool);
approveAndCall
*Sets a value
amount of tokens as the allowance of spender
over the
caller's tokens and then calls IERC1363Spender-onApprovalReceived on spender
.
Returns a flag that indicates if the call succeeded.
Requirements:
- The target has code (i.e. is a contract).
- The target
spender
must implement the {IERC1363Spender} interface. - The target must return the {IERC1363Spender-onApprovalReceived} selector to accept the approval.
- The internal {approve} must succeed (returned
true
).*
function approveAndCall(address spender, uint256 value) public returns (bool);
approveAndCall
Variant of approveAndCall that accepts an additional data
parameter with
no specified format.
function approveAndCall(address spender, uint256 value, bytes memory data) public virtual returns (bool);
Errors
ERC1363TransferFailed
Indicates a failure within the {transfer} part of a transferAndCall operation.
error ERC1363TransferFailed(address receiver, uint256 value);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | Address to which tokens are being transferred. |
value | uint256 | Amount of tokens to be transferred. |
ERC1363TransferFromFailed
Indicates a failure within the {transferFrom} part of a transferFromAndCall operation.
error ERC1363TransferFromFailed(address sender, address receiver, uint256 value);
Parameters
Name | Type | Description |
---|---|---|
sender | address | Address from which to send tokens. |
receiver | address | Address to which tokens are being transferred. |
value | uint256 | Amount of tokens to be transferred. |
ERC1363ApproveFailed
Indicates a failure within the {approve} part of a approveAndCall operation.
error ERC1363ApproveFailed(address spender, uint256 value);
Parameters
Name | Type | Description |
---|---|---|
spender | address | Address which will spend the funds. |
value | uint256 | Amount of tokens to be spent. |