ERC-1363 Standard Explained

The ERC-20 standard lacks the capability to notify a token recipient or verify if they are capable of handling the tokens received.

There is no method to trigger code execution on a receiver or spender contract following an ERC-20 transfer, `transferFrom,` or `approve` operations. Hence, to perform an action, users must initiate another transaction and incur gas fees twice in this process. This deficiency is exactly the reason for the ERC-1363. It is an extension for ERC-20 tokens for executing callbacks on receiver contracts.

This proposal aims to make tokens capable of performing actions more easily and working without the use of any off-chain listener. It allows the execution of a callback on a receiver/spender after a transfer or approval in a single transaction.

Backward Compatibility?

Contrary to some proposals extending ERC-20, ERC-1363 maintains backward compatibility with ERC-20 to ensure legacy protocols can still interact with it.

It is simply an ERC20 compatible contract with six extra functions, namely transferAndCall(2 versions), transferFromAndCall(2 versions), approveAndCall(2 versions).

So, nomenclatures such as name, decimals, symbol, approve, balanceOf, transfer, transferFrom, and allowance behave just like they would in the ERC-20 standard.

Functions and callbacks introduced by ERC-1363

The following are functions and callbacks recognized in the ERC-1363 standard:

The transferAndCall and transferFromAndCall will call an onTransferReceived on an ERC1363Receiver contract. While the approveAndCall will call an onApprovalReceived on an ERC1363Spender contract.

Note: The inclusion of the data parameter enables the sender to pass data to the receiving contract.

The choice to use transferAndCall, transferFromAndCall, and approveAndCall was influenced by the naming conventions similar to transfer, transferFrom, and approve in ERC-20 while emphasizing the inclusion of callbacks on receiver or spender contracts. And the ERC1363Receiver and ERC1363Spender were inspired by the ERC-721 onERC721Received and ERC721TokenReceiver behaviours.

Security Considerations:

It goes without saying that such functions with hooks will expose inherent security risks.

Link to the article