BNS Upgrade: Contract approvals

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 one spender can be set for a specific token-id. Setting spender as none is equivalent to removing any spender for this specific token-id.
  • (set-approval-for-all ((spender principal) (approved bool))): approve or withdraw approval for a specific spender from 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 specific spender is approved for all names for a specific owner.

Functionality where these methods would be used are:

  • In the transfer method, in addition to existing standard authorization for transactions from the NFT owner, checks would be included to determine whether contract-caller is a valid spender for a specific name.
  • In the transfer method, if there exists a token-specific approval for the name being transferred, that approval is removed.

References:

Another use case might be a company-owned name delegating control over what values the name points to one or more particular employees and being able to revoke that permission.