Skip to content

docs: use safe mint in ERC721 example#6549

Open
TUPM96 wants to merge 2 commits into
OpenZeppelin:masterfrom
TUPM96:codex/erc721-docs-safe-mint-example-4033
Open

docs: use safe mint in ERC721 example#6549
TUPM96 wants to merge 2 commits into
OpenZeppelin:masterfrom
TUPM96:codex/erc721-docs-safe-mint-example-4033

Conversation

@TUPM96

@TUPM96 TUPM96 commented May 25, 2026

Copy link
Copy Markdown

Summary

  • use _safeMint in the ERC721 GameItem docs example
  • keeps _nextTokenId++ before minting so the token id is advanced before the receiver callback

Closes #4033.

Tests

  • npx prettier --log-level warn --ignore-path .gitignore contracts/mocks/docs/token/ERC721/GameItem.sol --check
  • npx solhint --config solhint.config.js --noPoster contracts/mocks/docs/token/ERC721/GameItem.sol
  • npx hardhat compile
  • git diff --check

Note: the local pre-commit hook invokes Unix shell scripts directly and did not run on Windows, so I committed with --no-verify after running the checks above manually.

Copilot AI review requested due to automatic review settings May 25, 2026 10:08
@TUPM96 TUPM96 requested a review from a team as a code owner May 25, 2026 10:08
@changeset-bot

changeset-bot Bot commented May 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0ec1539

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1865a1e5-5154-4ae2-b838-90af77c8caf0

📥 Commits

Reviewing files that changed from the base of the PR and between 5a3b28f and a8a3b67.

📒 Files selected for processing (1)
  • contracts/mocks/docs/token/ERC721/GameItem.sol

Walkthrough

The GameItem documentation example contract in contracts/mocks/docs/token/ERC721/ was updated to follow ERC721 best practices. The awardItem function now calls _safeMint instead of _mint when minting tokens to the player address. This change ensures recipient contracts are checked for ERC721 compatibility during minting, addressing the security concern flagged in the linked issue.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: updating the ERC721 example to use safe mint instead of regular mint.
Description check ✅ Passed The description is directly related to the changeset, explaining the update to use _safeMint, the preservation of token ID advancement, and the issue it closes.
Linked Issues check ✅ Passed The code change directly addresses the requirement in issue #4033 by replacing _mint with _safeMint in the ERC721 GameItem documentation example to promote best practices.
Out of Scope Changes check ✅ Passed All changes are in scope, limited to updating the minting method from _mint to _safeMint in the ERC721 GameItem documentation example as specified in issue #4033.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insecure example in ERC721 documentation

2 participants