Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Royalties for NFTs #70

Open
5 tasks
JulissaDantes opened this issue Dec 15, 2021 · 4 comments · May be fixed by #151
Open
5 tasks

Add Royalties for NFTs #70

JulissaDantes opened this issue Dec 15, 2021 · 4 comments · May be fixed by #151

Comments

@JulissaDantes
Copy link

JulissaDantes commented Dec 15, 2021

Add options for users to be able to integrate royalties on their ERC721 and ERC1155 contracts. This is a suggested set of changes:

  • Include it on the options after selecting ERC721 or ERC1155.
    image
    Populating those fields would inherit from the tokenRoyalty contract and call the setDefaultRoyalty from the constructor.

  • Include this parts on the code:

    • An import for the new module: import "@openzeppelin/contracts/token/tokenERC/extensions/tokenERCRoyalty.sol";
    • An inheritance: contract MyToken is ERC721, AccessControl { We'll use Access control to handle the roles of who can set royalties.
    • This calls to the royalties functions:
    function setTokenRoyalty(
        uint256 tokenId,
        address recipient,
        uint96 fraction
    ) public onlyRole(ROYALTY_SETTER_ROLE) {
        _setTokenRoyalty(tokenId, recipient, fraction);
    }

    function setDefaultRoyalty(address recipient, uint96 fraction) public onlyRole(ROYALTY_SETTER_ROLE) {
        _setDefaultRoyalty(recipient, fraction);
    }
- [ ] This constructor: 
bytes32 public constant ROYALTY_SETTER_ROLE= keccak256("ROYALTY_SETTER_ROLE");
constructor() ERC721("MyToken", "MTK") {
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _grantRole(ROYALTY_SETTER_ROLE, msg.sender);
    }

Take into consideration for the ERC1155, if the user specifies royalties and select ERC1155Supply do not import it btwice into the code, since the royalties contract inherits from this module.

@JulissaDantes JulissaDantes changed the title Add ERC721 Royalty Feature Add Royalty Feature Dec 21, 2021
@frangio
Copy link
Contributor

frangio commented Dec 21, 2021

Let's remove the part about access control. I don't think a "royalty setter" role is the way this will be used in general.

Populating those fields would inherit from the tokenRoyalty contract and call the setDefaultRoyalty from the constructor.

This should be enough to get started.

@SudarminThen
Copy link

Would like to see this to be implemented too, will this be implemented in the future?

@gmertk
Copy link

gmertk commented Jan 3, 2022

Hello,

I was just looking into this project today.

I have a diff for this on gmertk@29d903e

If it is ok for you, I can send a pull request after OpenZeppelin/openzeppelin-contracts#3012 is merged.

Cheers!

@frangio
Copy link
Contributor

frangio commented Jan 6, 2022

That's awesome @gmertk! Feel free to open a Draft PR any time and we can begin reviewing. It's not going to be merged until royalties are released in OpenZeppelin Contracts later this month.

@frangio frangio changed the title Add Royalty Feature Add Royalties for NFTs Apr 8, 2022
@frangio frangio linked a pull request Dec 24, 2022 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants