Skip to content

Commit c92ddef

Browse files
authored
Enhance documentation in TokenCallbackHandler with ERC-1820 registration details (#885)
This PR adds a detailed comment in the TokenCallbackHandler contract, clarifying the requirement for accounts to register the implementer via the ERC-1820 interface registry to receive ERC777 tokens. This update aims to improve clarity and understanding of the token reception process. No functional changes were made to the contract logic.
1 parent c6cd4b9 commit c92ddef

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

contracts/handler/TokenCallbackHandler.sol

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import {IERC165} from "../interfaces/IERC165.sol";
1313
contract TokenCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ERC721TokenReceiver, IERC165 {
1414
/**
1515
* @notice Handles ERC1155 Token callback.
16-
* return Standardized onERC1155Received return value.
16+
* @return Standardized onERC1155Received return value.
1717
*/
1818
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure override returns (bytes4) {
1919
return 0xf23a6e61;
2020
}
2121

2222
/**
2323
* @notice Handles ERC1155 Token batch callback.
24-
* return Standardized onERC1155BatchReceived return value.
24+
* @return Standardized onERC1155BatchReceived return value.
2525
*/
2626
function onERC1155BatchReceived(
2727
address,
@@ -35,15 +35,18 @@ contract TokenCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ER
3535

3636
/**
3737
* @notice Handles ERC721 Token callback.
38-
* return Standardized onERC721Received return value.
38+
* @return Standardized onERC721Received return value.
3939
*/
4040
function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) {
4141
return 0x150b7a02;
4242
}
4343

4444
/**
4545
* @notice Handles ERC777 Token callback.
46-
* return nothing (not standardized)
46+
* @dev Account that wishes to receive the tokens also needs to register the implementer (this contract) via the ERC-1820 interface registry.
47+
* From the standard: "This is done by calling the setInterfaceImplementer function on the ERC-1820 registry with the holder address as
48+
* the address, the keccak256 hash of ERC777TokensSender (0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895) as the
49+
* interface hash, and the address of the contract implementing the ERC777TokensSender as the implementer."
4750
*/
4851
function tokensReceived(address, address, address, uint256, bytes calldata, bytes calldata) external pure override {
4952
// We implement this for completeness, doesn't really have any value

0 commit comments

Comments
 (0)