我试图为版税实现ERC2981,但希望使用OpenZepplins支付分离器将版税金额分成两个不同的地址和两个不同的金额。我找不到两者结合在一起的任何例子。我理解如何将这些值传递给PaymentSplitter的构造函数,但不确定如何为保留性方法设置这些值。下面是代码的一个示例:
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);
} 发布于 2022-04-12 09:27:50
EIP-2981只接受一个地址作为版税接受者,因此分期付款逻辑应该在该地址上。
https://ethereum.stackexchange.com/questions/120641
复制相似问题