# What is ERC-721 in smart contracts?

URL: https://shield.quillaudits.com/learn/glossary/erc-721/

ERC-721 is the standard for non-fungible tokens: each token has a unique ID and exactly one owner, and the contract tracks ownership and approvals per ID. It was created in January 2018 and is final as [EIP-721](https://eips.ethereum.org/EIPS/eip-721), and collectibles, tickets and liquidity positions are common uses.

Last updated 3 December 2026. 2 minute read. By the QuillAudits Team.

## What does the standard define?

The interface has nine functions, `balanceOf`, `ownerOf`, two `safeTransferFrom` variants, `transferFrom`, `approve`, `setApprovalForAll`, `getApproved` and `isApprovedForAll`, and it uses ERC-165 for interface detection ([EIP-721](https://eips.ethereum.org/EIPS/eip-721)).

The safe transfer is the part that matters for security. After the transfer, it checks whether the recipient has code and, if so, calls `onERC721Received` on the recipient and reverts unless it gets back the selector of that function. Plain `transferFrom` skips the check, and the standard warns that tokens sent to a contract that can't handle them may be lost for good ([EIP-721](https://eips.ethereum.org/EIPS/eip-721)).

## How does a safe mint become a reentrancy bug?

A mint that runs the same receiver check hands control to the minting contract in the middle of the mint. If the limit is enforced on a counter updated after that call, the receiver can mint again from inside the callback.

**A one-per-address mint that its own callback can bypass (illustrative, not audited code)** `LimitedMint.sol`

```
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

interface IERC721Receiver {
    function onERC721Received(address operator, address from, uint256 id, bytes calldata data)
        external
        returns (bytes4);
}

contract LimitedMint {
    uint256 public nextId;
    mapping(uint256 => address) public ownerOf;
    mapping(address => uint256) public minted;

    function mint() external {
        require(minted[msg.sender] == 0, "one per address");
        uint256 id = nextId++;
        ownerOf[id] = msg.sender;
        if (msg.sender.code.length > 0) {
            bytes4 reply = IERC721Receiver(msg.sender).onERC721Received(msg.sender, address(0), id, "");
            require(reply == IERC721Receiver.onERC721Received.selector, "unsafe recipient");
        }
        minted[msg.sender] += 1; // too late: the callback above can call mint() again
    }
}
```

Move the `minted` update above the callback, or add a [reentrancy guard](https://shield.quillaudits.com/learn/glossary/reentrancy-guard/), and the second mint fails.

- Limits, prices and supply caps are checked and updated before any receiver callback.
- Batch mints don't make a callback per token before the accounting for the batch is done.
- Contracts that receive NFTs check which collection called their `onERC721Received`.

## Sources

- [ERC-721: Non-Fungible Token Standard, Ethereum Improvement Proposals](https://eips.ethereum.org/EIPS/eip-721) · checked 3 December 2026
