首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ERC-2981的OpenZepplin付款分离器支付版税

使用ERC-2981的OpenZepplin付款分离器支付版税
EN

Ethereum用户
提问于 2022-02-03 03:12:56
回答 1查看 1.4K关注 0票数 2

我试图为版税实现ERC2981,但希望使用OpenZepplins支付分离器将版税金额分成两个不同的地址和两个不同的金额。我找不到两者结合在一起的任何例子。我理解如何将这些值传递给PaymentSplitter的构造函数,但不确定如何为保留性方法设置这些值。下面是代码的一个示例:

代码语言:javascript
复制
  constructor(string memory _name, string memory _symbol, address[] memory _payees, uint256[] memory _shares
    ) ERC721(_name, _symbol) PaymentSplitter(_payees, _shares) payable {

        //Need to figure out how to set _royalities.recipient to _payees and _royalties.salePrice to _shares

        console.log("Testing test deploy", _name, _symbol);
    }
  
  function _setTokenRoyalty(uint256 tokenId, address recipient, uint256 salePrice) internal {
      //This is so expected 'value' will be at most 10,000 which is 100%
      require(salePrice <= 10000, "ERC2981Royalities: Too high");

      //How can I set the recipient to use the array of _payees and _shares here?
      _royalties[tokenId] = Royalty(recipient, salePrice);
  }

  function royaltyInfo(uint256 tokenId, uint256 salePrice)
    external
    view
    override
    returns (address receiver, uint256 royaltyAmount)
  {
      require(_exists(tokenId), "Nonexistent token");

      if(_royalties[tokenId].recipient != address(0)) {
          return (_royalties[tokenId].recipient, salePrice * _royalties[tokenId].salePrice / 10000);
      }
      Royalty memory royalty = _royalties[tokenId];
      if(royalty.recipient != address(0) && royalty.salePrice != 0) {
          return (royalty.recipient, (salePrice * royalty.salePrice) / 10000);
      }
      return (address(0), 0);
  } 
EN

回答 1

Ethereum用户

发布于 2022-04-12 09:27:50

EIP-2981只接受一个地址作为版税接受者,因此分期付款逻辑应该在该地址上。

https://eips.ethereum.org/EIPS/eip-2981

票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/120641

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档