Say I want to take a cut of an NFT each time the token is transferred. If I were to change the openzeppelin erc721 transfer function to transfer 1% of the NFTs holding to myself, can that standard still be used in exchanges?
I'm currently evaluating the same. Was thinking if it would be possible to higher the gas transfer price to then cut x percent and send this to a constant wallet.
Still unsure if this would work, but I think what you originally would do is a Royaltie, that could been integrated like this, but only works on exchanges: https://eips.ethereum.org/EIPS/eip-2981
If someone has an idea for putting a fee into the transfer action would be nice to hear.
If it implements all functions on the IERC721 interface is not falling from the standard. As @Airwave mentioned there is the
EIP2981 standard for royalties and you can see OpenZeppen implementation here, that is still under revision and to be released on their next version but right now is on the open review period.
Your override of the transfer method should just include a call to the EIP2981
royaltyInfo function, and send the returned
royaltyAmount to the returned
receiver that would be you in your case. And remember to call the method to set the royalty before executing any transfer.
Disclaimer: I do work at OpenZeppelin but this answer was written as a personal contribution.
Eip 2981 exists, but this is the age old problem of how do you know the amount an nft is being sold for? If exchanges are nice enough to tell you use eip 2981 or whatever system they have, but on a contract level there is not really a way to know. How do you differentiate between a sale and a friend transferring the nft to another friend as a gift? How do you stop payments on the nft from being very small while the actual payment occurs though a side channel of another transaction? Fundamentally this is a problem mostly for exchanges, but also never truely solvable without removing a lot of the freedom for people to use nfts as a transferable asset.