This post is part of a larger effort to discuss potential features to be included in an upgraded version of BNS. Please see the megathread for more information.
Proposal: include functionality similar to ERC721 for approvals.
“Approvals” is a mechanism for allowing users to approve specific contracts to interact with their NFTs without the user creating a transaction.
A common use-case for approvals is for non-custodial marketplace mechanisms. Users want to be able to list their NFT without transferring their NFT to a separate contract. Many Stacks NFTs have implemented “non-custodial marketplace” functionality to satisfy this desire.
While functions like list-in-ustx allow for the most common marketplace use case, it doesn’t allow for a broader range of desired functionality. For example, it only allows for one specific type of listing.
Implementing an approval interface would allow for a broader range of use-cases. For example, this would enable non-custodial auctions and other types of listings, such as off-chain signature-based listings on OpenSea.
Below is a rough specification of the methods this proposal would include.
(approve ((spender (optional principal)) (token-id uint)))- allow an owner to approve a contract to interact with a specific name. When using this method, only onespendercan be set for a specifictoken-id. Settingspenderasnoneis equivalent to removing any spender for this specifictoken-id.(set-approval-for-all ((spender principal) (approved bool))): approve or withdraw approval for a specificspenderfrom having the ability to move any name.(get-approved ((id uint))): fetch the current approved spender for a specific name(is-approved-for-all ((spender principal) (owner principal))): fetch whether a specificspenderis approved for all names for a specificowner.
Functionality where these methods would be used are:
- In the
transfermethod, in addition to existing standard authorization for transactions from the NFT owner, checks would be included to determine whethercontract-calleris a valid spender for a specific name. - In the
transfermethod, if there exists a token-specific approval for the name being transferred, that approval is removed.
References: