Can someone explain the use of zero address in ERC721 NFT transfer events?

I’m diving into NFT smart contracts and I’m confused about something in the minting process. Why does the Transfer event use address(0) as the ‘from’ address when minting a new token?

Here’s a simplified version of what I’m looking at:

function mintToken(address recipient, uint256 tokenId) internal {
    require(recipient != address(0), "Can't mint to zero address");
    require(!tokenExists(tokenId), "Token already exists");

    balances[recipient] += 1;
    tokenOwners[tokenId] = recipient;

    emit TokenCreated(address(0), recipient, tokenId);
}

event TokenCreated(address indexed source, address indexed destination, uint256 indexed tokenId);

I get that address(0) is like an empty address, but why use it here? Is it because the token is new and didn’t come from anywhere? It just feels weird to me. Can someone help me understand the logic behind this?

hey hugo, thats a great question! im also pretty new to nft stuff and was wondering about that too. have u looked into other token standards? i wonder if they use the same approach or if its unique to erc721. maybe theres a reason why they chose address(0) instead of like, a special minting address or something? anyway, im curious to hear what others think about this. do u think it could cause any issues or is it just a quirk of the standard?

yeah, ur right about that. the zero address is used cuz the token’s brand new and didn’t exist b4. its like saying it came from nowhere. its a convention in erc721 to show its a mint, not a transfer. helps track token lifecycle easier. makes sense once u get used to it!