简体   繁体   English

将版税添加到 Solidity NFT 智能合约

[英]Add Royalty to solidity NFT smart contract

how can I add royalty to Nft collection at the smart contract level, without using solutions from marketplaces?如何在不使用市场解决方案的情况下在智能合约级别向 Nft 收藏添加版税?

I use https://github.com/scaffold-eth this official repo for my task我使用https://github.com/scaffold-eth这个官方仓库来完成我的任务

The only way to add royalties at the smart contract level without breaking the ER721 Standard is to implement a custom transferFrom function which requires the royalty be paid on every transfer.在不违反ER721 标准的情况下,在智能合约级别添加版税的唯一方法是实施自定义transferFrom function,这需要在每次转账时支付版税。

This is generally not implemented because it means that users cannot transfer between their wallets without paying the royalty.这通常不会实施,因为这意味着用户无法在不支付版税的情况下在他们的钱包之间进行转账。

There is an EIP around NFT royalties to suggest a standard for defining on-chain royalties, however, marketplaces would still be responsible for enforcing the standard.有一个围绕 NFT 版税的EIP提出了定义链上版税的标准,但是,市场仍将负责执行该标准。

If you are not relying on third party marketplaces, then you could add a 'trade' function to your NFT, which implements the logic for an exchange between a currency and the NFT.如果你不依赖第三方市场,那么你可以在你的 NFT 中添加一个“交易”function,它实现了货币和 NFT 之间交换的逻辑。 However, this would not be used by marketplaces like OpenSea and would only be a viable solution if you plan to implement your own marketplace.但是,这不会被 OpenSea 等市场使用,并且只有在您计划实施自己的市场时才会成为可行的解决方案。

There is EIP-2981 .EIP-2981

The Royalty smart contract from thirdweb is an extension usable with any base smart contract.来自thirdweb 的Royalty智能合约是可用于任何基础智能合约的扩展。 It implements EIP-2981 NFT royalty standard for royalty support on NFT marketplaces.它实施了 EIP-2981 NFT 版税标准,以在 NFT 市场上提供版税支持。

But there is another proposal from manifold as well: royalty-registry但也有来自多方面的另一个建议:版税注册

It provides the ability for contracts that did not originally support any of the on-chain Royalty specifications to add this functionality to their smart contract.它为最初不支持任何链上版税规范的合约提供了将此功能添加到其智能合约的能力。 A reference EIP-2981 override implementation can be found here: https://github.com/manifoldxyz/royalty-registry-solidity/blob/main/contracts/overrides/RoyaltyOverride.sol .可以在此处找到参考 EIP-2981 覆盖实现: https://github.com/manifoldxyz/royalty-registry-solidity/blob/main/contracts/overrides/RoyaltyOverride.sol

Still, market places actually may not use this information.尽管如此,市场实际上可能不会使用这些信息。 Your smart contract still lets the transfer to happen without the royalty fee.您的智能合约仍然允许在不收取特许权使用费的情况下进行转移。 eg Sudoswap and now X2Y2 let the seller-buyer decide to pay the royalty fees or not.例如 Sudoswap 和现在的 X2Y2 让买卖双方决定是否支付特许权使用费。

To avoid that make a simple tweak to the approval methods in ERC721 that whitelist specific marketplaces:https://gist.github.com/cygaar/6d908d1eb12727d94583ad20b84a06eb为避免这种情况,对 ERC721 中将特定市场列入白名单的批准方法进行简单调整:https://gist.github.com/cygaar/6d908d1eb12727d94583ad20b84a06

Here is a contract where the owner can allow trading on certain marketplaces explicitly by calling the function:这是一个合约,所有者可以通过调用 function 明确地允许在某些市场上进行交易:

setApprovedMarketplace(address market, bool approved)

In this case, you could only approve marketplaces that honor royalties.在这种情况下,您只能批准支付版税的市场。

https://thirdweb.com/joenrv.eth/ERC721DropRestrictedMarkets https://thirdweb.com/joenrv.eth/ERC721DropRestrictedMarkets

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM