diff --git a/contracts/token/ERC1155/IERC1155Receiver.sol b/contracts/token/ERC1155/IERC1155Receiver.sol index 4e016cf0f..b7f7f7373 100644 --- a/contracts/token/ERC1155/IERC1155Receiver.sol +++ b/contracts/token/ERC1155/IERC1155Receiver.sol @@ -10,18 +10,20 @@ import "../../utils/introspection/IERC165.sol"; */ interface IERC1155Receiver is IERC165 { /** - @dev Handles the receipt of a single ERC1155 token type. This function is - called at the end of a `safeTransferFrom` after the balance has been updated. - To accept the transfer, this must return - `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` - (i.e. 0xf23a6e61, or its own function selector). - @param operator The address which initiated the transfer (i.e. msg.sender) - @param from The address which previously owned the token - @param id The ID of the token being transferred - @param value The amount of tokens being transferred - @param data Additional data with no specified format - @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed - */ + * @dev Handles the receipt of a single ERC1155 token type. This function is + * called at the end of a `safeTransferFrom` after the balance has been updated. + * + * NOTE: To accept the transfer, this must return + * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` + * (i.e. 0xf23a6e61, or its own function selector). + * + * @param operator The address which initiated the transfer (i.e. msg.sender) + * @param from The address which previously owned the token + * @param id The ID of the token being transferred + * @param value The amount of tokens being transferred + * @param data Additional data with no specified format + * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed + */ function onERC1155Received( address operator, address from, @@ -31,18 +33,21 @@ interface IERC1155Receiver is IERC165 { ) external returns (bytes4); /** - @dev Handles the receipt of a multiple ERC1155 token types. This function - is called at the end of a `safeBatchTransferFrom` after the balances have - been updated. To accept the transfer(s), this must return - `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` - (i.e. 0xbc197c81, or its own function selector). - @param operator The address which initiated the batch transfer (i.e. msg.sender) - @param from The address which previously owned the token - @param ids An array containing ids of each token being transferred (order and length must match values array) - @param values An array containing amounts of each token being transferred (order and length must match ids array) - @param data Additional data with no specified format - @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed - */ + * @dev Handles the receipt of a multiple ERC1155 token types. This function + * is called at the end of a `safeBatchTransferFrom` after the balances have + * been updated. + * + * NOTE: To accept the transfer(s), this must return + * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` + * (i.e. 0xbc197c81, or its own function selector). + * + * @param operator The address which initiated the batch transfer (i.e. msg.sender) + * @param from The address which previously owned the token + * @param ids An array containing ids of each token being transferred (order and length must match values array) + * @param values An array containing amounts of each token being transferred (order and length must match ids array) + * @param data Additional data with no specified format + * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed + */ function onERC1155BatchReceived( address operator, address from, diff --git a/contracts/token/ERC1155/README.adoc b/contracts/token/ERC1155/README.adoc index c41793205..2e0b22bae 100644 --- a/contracts/token/ERC1155/README.adoc +++ b/contracts/token/ERC1155/README.adoc @@ -26,6 +26,8 @@ NOTE: This core set of contracts is designed to be unopinionated, allowing devel {{IERC1155Receiver}} +{{ERC1155Receiver}} + == Extensions {{ERC1155Pausable}} diff --git a/contracts/token/ERC1155/utils/ERC1155Holder.sol b/contracts/token/ERC1155/utils/ERC1155Holder.sol index e24d006b3..d11aa0567 100644 --- a/contracts/token/ERC1155/utils/ERC1155Holder.sol +++ b/contracts/token/ERC1155/utils/ERC1155Holder.sol @@ -6,6 +6,11 @@ pragma solidity ^0.8.0; import "./ERC1155Receiver.sol"; /** + * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens. + * + * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be + * stuck. + * * @dev _Available since v3.1._ */ contract ERC1155Holder is ERC1155Receiver {