From 9d34eb49661b43a56aa4325abac9f84960accc4f Mon Sep 17 00:00:00 2001 From: Hyungsuk Kang Date: Fri, 14 Jan 2022 15:02:13 +0900 Subject: [PATCH 1/2] Add burn feature --- ERC721A.sol | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ERC721A.sol b/ERC721A.sol index c418f2568..8473df560 100644 --- a/ERC721A.sol +++ b/ERC721A.sol @@ -43,6 +43,8 @@ contract ERC721A is uint256 private currentIndex = 0; uint256 internal immutable maxBatchSize; + + address private burned = address(1); // Token name string private _name; @@ -325,6 +327,25 @@ contract ERC721A is function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } + + function _safeBurn(uint256 tokenId) internal { + _safeBurn(tokenId); + } + + /** + * @dev Burns a certain token from id. + * + * Emits a {Transfer} event. + */ + function _safeBurn( + uint256 tokenId, + bytes memory _data + ) internal { + TokenOwnership memory prevOwnership = ownershipOf(tokenId); + _addressData[prevOwnership.addr].balance -= 1; + _ownerships[tokenId] = TokenOwnership(burned, uint64(block.timestamp)); + emit Transfer(prevOwnership.addr, burned, tokenId); + } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); From b0a5eff7300fe52e38e3b708180928b47869e86d Mon Sep 17 00:00:00 2001 From: Hyungsuk Kang Date: Sat, 29 Jan 2022 13:59:18 +0900 Subject: [PATCH 2/2] Update ERC721A.sol --- ERC721A.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERC721A.sol b/ERC721A.sol index 8473df560..14a8dc982 100644 --- a/ERC721A.sol +++ b/ERC721A.sol @@ -329,7 +329,7 @@ contract ERC721A is } function _safeBurn(uint256 tokenId) internal { - _safeBurn(tokenId); + _safeBurn(tokenId, ""); } /**