-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
P4: nice-to-haveLow priority improvementLow priority improvementenhancementNew feature or requestNew feature or request
Description
Summary
The ERC-721 contract in Contracts/ERC721/ERC721.lean is missing safeTransferFrom, which is required for full ERC-721 compliance (EIP-721). This is a contract-level change only — all needed EDSL primitives already exist.
Current ERC-721 surface
Implemented: balanceOf, ownerOf, getApproved, isApprovedForAll, approve, setApprovalForAll, mint, transferFrom
Missing: safeTransferFrom(from, to, tokenId), safeTransferFrom(from, to, tokenId, data)
Implementation
safeTransferFrom = transferFrom + recipient contract check:
- Call
transferFrom(from, to, tokenId)(already implemented) - Check if
tois a contract (extcodesize(to) > 0) —extcodesizealready exists as anExpr - If contract, call
onERC721Received(operator, from, tokenId, data)onto— achievable viaecmCall/Calls.withReturnECM - Require return value equals selector
0x150b7a02
Both overloads (with and without data parameter) should be implemented.
Proof considerations
The transferFrom portion has existing proofs (ownership transfer, approval checks). The onERC721Received callback is an external call — it should be:
- A
local_obligationat the proof level (the callback's behavior is outside the single-contract model) - Tested via Foundry (receiver contract that returns correct/incorrect selector)
Definition of done
-
safeTransferFrom(from, to, tokenId)implemented inContracts/ERC721/ERC721.lean -
safeTransferFrom(from, to, tokenId, data)implemented (overload with bytes data) -
extcodesizecheck for contract recipients -
onERC721Receivedcallback via ECM for contract recipients - Callback declared as
local_obligation - Foundry tests: transfer to EOA succeeds, transfer to compliant contract succeeds, transfer to non-compliant contract reverts
- Existing ERC-721 proofs still pass
-
safeTransferFrominheritstransferFromproof properties (ownership transfer, approval checks)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P4: nice-to-haveLow priority improvementLow priority improvementenhancementNew feature or requestNew feature or request