You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NFT: get_approved returns None instead of NonExistentToken for nonexistent tokens #934
NonFungibleToken::get_approved returns None for token IDs that don't exist, both never-minted IDs and burned ones. Its docs list NonFungibleTokenError::NonExistentToken for that case, but the error is never raised.
The default ContractOverrides::get_approved calls Base::get_approved, which only reads the temporary Approval(token_id) entry and never checks that the token exists. No NFT contract type overrides get_approved, so this affects Base, Enumerable, Consecutive, NonFungibleVotes and the combined types.
As a result, a caller can't tell a live token with no approval apart from a token that doesn't exist. Ownership, balances, transfers and approvals on live tokens are not affected.
get_approved panics with NonExistentToken (#200) for a token that doesn't exist, as documented on the trait. This matches owner_of and token_uri, SEP-50, and Solidity's ERC721.getApproved.
The existence check has to go through Self::owner_of (the contract type's own ownership model), not Base::owner_of. Consecutive doesn't store a per-token owner entry for batch-minted tokens, so Base::owner_of would wrongly reject them. This is the same approach RoyaltySupport::royalty_info uses (#846).
Activity
ozgunozerk commentedon Oct 13, 2026
We will have a better solution for this for accurate errors for consecutive