Skip to content

Commit 59315b5

Browse files
committed
per comments from nventuro, add an event to flag the existence of this token ID
1 parent 1f6d1fe commit 59315b5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

contracts/token/ERC1155/ERC1155.sol

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,17 @@ contract ERC1155 is ERC165, IERC1155
201201
/**
202202
* @dev Register a token ID so other contract functionality knows this token
203203
* actually exists and this ID is valid. Minting will automatically call this.
204+
* Also emits an event to flag the existence, see the spec:
205+
* "To broadcast the existence of a token ID with no initial balance, the contract
206+
* SHOULD emit the TransferSingle event from 0x0 to 0x0, with the token creator as
207+
* _operator, and a _value of 0."
204208
* @param id uint256 ID of the token to register
205209
*/
206210
function _registerToken(uint256 id) internal virtual {
207-
_tokenExists[id] = true;
211+
if (!_tokenExists[id]) {
212+
_tokenExists[id] = true;
213+
emit TransferSingle(msg.sender, address(0), address(0), id, 0);
214+
}
208215
}
209216

210217
/**

0 commit comments

Comments
 (0)