[
  {
    "path": ".gitignore",
    "content": "node_modules\n\n#Hardhat files\ncache\nartifacts\n\n.env*\n!.env.SAMPLE"
  },
  {
    "path": ".prettierrc",
    "content": "{\n\t\"trailingComma\": \"all\",\n\t\"tabWidth\": 4,\n\t\"useTabs\": false,\n\t\"semi\": true,\n\t\"singleQuote\": true\n}"
  },
  {
    "path": ".solhint.json",
    "content": "{\n  \"extends\": \"solhint:default\"\n}"
  },
  {
    "path": "README.md",
    "content": "# EIP-2981 Example\n\n## Resume\n\nSimple example of implementation of EIP-2981.\n\nIn all implementations, royalties are expected to be from 0 to 10000 which allows to define royalties with 2 decimals.\n\n### Contract wide royalties\n\nThe contract `ERC2981ContractWideRoyalties.sol` implements ERC2981 with every token having the same royalties recipient and amount.\n\n\n`./contracts/mocks/ERC721WithContractWideRoyalties.sol` is an example of ERC721 that would work on a contract-wide royalty base.\n\n\n### Per Token royalties\n\nThe contract `ERC2981PerTokenRoyalties.sol` implements ERC2981 with every token having different royalties\n\nThe contracts\n\n- `./contracts/mocks/ERC721WithRoyalties.sol`\n- `./contracts/mocks/ERC1155WithRoyalties.sol`\n\nshow how to extend ERC2981 to set royalties at minting time.\n\n## Installation\n\nClone this repository using your favorite tool (i.e: `git clone git@github.com:dievardump/EIP2981-implementation.git`)\n\nIn the directory of installation:\n\n`npm install`\n\n## Compilation\n\n`npm run compile`\n\n## Tests\n\n`npm run test`\n"
  },
  {
    "path": "contracts/ERC2981Base.sol",
    "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/ERC165.sol';\n\nimport './IERC2981Royalties.sol';\n\n/// @dev This is a contract used to add ERC2981 support to ERC721 and 1155\nabstract contract ERC2981Base is ERC165, IERC2981Royalties {\n    struct RoyaltyInfo {\n        address recipient;\n        uint24 amount;\n    }\n\n    /// @inheritdoc\tERC165\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        virtual\n        override\n        returns (bool)\n    {\n        return\n            interfaceId == type(IERC2981Royalties).interfaceId ||\n            super.supportsInterface(interfaceId);\n    }\n}\n"
  },
  {
    "path": "contracts/ERC2981ContractWideRoyalties.sol",
    "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/ERC165.sol';\n\nimport './ERC2981Base.sol';\n\n/// @dev This is a contract used to add ERC2981 support to ERC721 and 1155\n/// @dev This implementation has the same royalties for each and every tokens\nabstract contract ERC2981ContractWideRoyalties is ERC2981Base {\n    RoyaltyInfo private _royalties;\n\n    /// @dev Sets token royalties\n    /// @param recipient recipient of the royalties\n    /// @param value percentage (using 2 decimals - 10000 = 100, 0 = 0)\n    function _setRoyalties(address recipient, uint256 value) internal {\n        require(value <= 10000, 'ERC2981Royalties: Too high');\n        _royalties = RoyaltyInfo(recipient, uint24(value));\n    }\n\n    /// @inheritdoc\tIERC2981Royalties\n    function royaltyInfo(uint256, uint256 value)\n        external\n        view\n        override\n        returns (address receiver, uint256 royaltyAmount)\n    {\n        RoyaltyInfo memory royalties = _royalties;\n        receiver = royalties.recipient;\n        royaltyAmount = (value * royalties.amount) / 10000;\n    }\n}\n"
  },
  {
    "path": "contracts/ERC2981PerTokenRoyalties.sol",
    "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/ERC165.sol';\n\nimport './ERC2981Base.sol';\n\n/// @dev This is a contract used to add ERC2981 support to ERC721 and 1155\nabstract contract ERC2981PerTokenRoyalties is ERC2981Base {\n    mapping(uint256 => RoyaltyInfo) internal _royalties;\n\n    /// @dev Sets token royalties\n    /// @param tokenId the token id fir which we register the royalties\n    /// @param recipient recipient of the royalties\n    /// @param value percentage (using 2 decimals - 10000 = 100, 0 = 0)\n    function _setTokenRoyalty(\n        uint256 tokenId,\n        address recipient,\n        uint256 value\n    ) internal {\n        require(value <= 10000, 'ERC2981Royalties: Too high');\n        _royalties[tokenId] = RoyaltyInfo(recipient, uint24(value));\n    }\n\n    /// @inheritdoc\tIERC2981Royalties\n    function royaltyInfo(uint256 tokenId, uint256 value)\n        external\n        view\n        override\n        returns (address receiver, uint256 royaltyAmount)\n    {\n        RoyaltyInfo memory royalties = _royalties[tokenId];\n        receiver = royalties.recipient;\n        royaltyAmount = (value * royalties.amount) / 10000;\n    }\n}\n"
  },
  {
    "path": "contracts/IERC2981Royalties.sol",
    "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @title IERC2981Royalties\n/// @dev Interface for the ERC2981 - Token Royalty standard\ninterface IERC2981Royalties {\n    /// @notice Called with the sale price to determine how much royalty\n    //          is owed and to whom.\n    /// @param _tokenId - the NFT asset queried for royalty information\n    /// @param _value - the sale price of the NFT asset specified by _tokenId\n    /// @return _receiver - address of who should be sent the royalty payment\n    /// @return _royaltyAmount - the royalty payment amount for value sale price\n    function royaltyInfo(uint256 _tokenId, uint256 _value)\n        external\n        view\n        returns (address _receiver, uint256 _royaltyAmount);\n}\n"
  },
  {
    "path": "contracts/mocks/ERC1155WithRoyalties.sol",
    "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/token/ERC1155/ERC1155.sol';\n\nimport '../ERC2981PerTokenRoyalties.sol';\n\n/// @title Example of ERC1155 contract with ERC2981\n/// @author Simon Fremaux (@dievardump)\n/// @notice This is a mock, mint and mintBatch are not protected. Please do not use as-is in production\ncontract ERC1155WithRoyalties is ERC1155, ERC2981PerTokenRoyalties {\n    constructor(string memory uri_) ERC1155(uri_) {}\n\n    /// @inheritdoc\tERC165\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        virtual\n        override(ERC1155, ERC2981Base)\n        returns (bool)\n    {\n        return super.supportsInterface(interfaceId);\n    }\n\n    /// @notice Mint amount token of type `id` to `to`\n    /// @param to the recipient of the token\n    /// @param id id of the token type to mint\n    /// @param amount amount of the token type to mint\n    /// @param royaltyRecipient the recipient for royalties (if royaltyValue > 0)\n    /// @param royaltyValue the royalties asked for (EIP2981)\n    function mint(\n        address to,\n        uint256 id,\n        uint256 amount,\n        address royaltyRecipient,\n        uint256 royaltyValue\n    ) external {\n        _mint(to, id, amount, '');\n\n        if (royaltyValue > 0) {\n            _setTokenRoyalty(id, royaltyRecipient, royaltyValue);\n        }\n    }\n\n    /// @notice Mint several tokens at once\n    /// @param to the recipient of the token\n    /// @param ids array of ids of the token types to mint\n    /// @param amounts array of amount to mint for each token type\n    /// @param royaltyRecipients an array of recipients for royalties (if royaltyValues[i] > 0)\n    /// @param royaltyValues an array of royalties asked for (EIP2981)\n    function mintBatch(\n        address to,\n        uint256[] memory ids,\n        uint256[] memory amounts,\n        address[] memory royaltyRecipients,\n        uint256[] memory royaltyValues\n    ) external {\n        require(\n            ids.length == royaltyRecipients.length &&\n                ids.length == royaltyValues.length,\n            'ERC1155: Arrays length mismatch'\n        );\n\n        _mintBatch(to, ids, amounts, '');\n\n        for (uint256 i; i < ids.length; i++) {\n            if (royaltyValues[i] > 0) {\n                _setTokenRoyalty(\n                    ids[i],\n                    royaltyRecipients[i],\n                    royaltyValues[i]\n                );\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "contracts/mocks/ERC721WithContractWideRoyalties.sol",
    "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/token/ERC721/ERC721.sol';\n\nimport '../ERC2981ContractWideRoyalties.sol';\n\n/// @title Example of ERC721 contract with ERC2981\n/// @author Simon Fremaux (@dievardump)\n/// @notice This is a mock, mint and mintBatch are not protected. Please do not use as-is in production\ncontract ERC721WithContractWideRoyalties is\n    ERC721,\n    ERC2981ContractWideRoyalties\n{\n    uint256 nextTokenId;\n\n    constructor(string memory name_, string memory symbol_)\n        ERC721(name_, symbol_)\n    {}\n\n    /// @inheritdoc\tERC165\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        virtual\n        override(ERC721, ERC2981Base)\n        returns (bool)\n    {\n        return super.supportsInterface(interfaceId);\n    }\n\n    /// @notice Allows to set the royalties on the contract\n    /// @dev This function in a real contract should be protected with a onlyOwner (or equivalent) modifier\n    /// @param recipient the royalties recipient\n    /// @param value royalties value (between 0 and 10000)\n    function setRoyalties(address recipient, uint256 value) public {\n        _setRoyalties(recipient, value);\n    }\n\n    /// @notice Mint one token to `to`\n    /// @param to the recipient of the token\n    function mint(address to) external {\n        uint256 tokenId = nextTokenId;\n        _safeMint(to, tokenId, '');\n\n        nextTokenId = tokenId + 1;\n    }\n\n    /// @notice Mint several tokens at once\n    /// @param recipients an array of recipients for each token\n    function mintBatch(address[] memory recipients) external {\n        uint256 tokenId = nextTokenId;\n        for (uint256 i; i < recipients.length; i++) {\n            _safeMint(recipients[i], tokenId, '');\n            tokenId++;\n        }\n\n        nextTokenId = tokenId;\n    }\n}\n"
  },
  {
    "path": "contracts/mocks/ERC721WithRoyalties.sol",
    "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/token/ERC721/ERC721.sol';\n\nimport '../ERC2981PerTokenRoyalties.sol';\n\n/// @title Example of ERC721 contract with ERC2981\n/// @author Simon Fremaux (@dievardump)\n/// @notice This is a mock, mint and mintBatch are not protected. Please do not use as-is in production\ncontract ERC721WithRoyalties is ERC721, ERC2981PerTokenRoyalties {\n    uint256 nextTokenId;\n\n    constructor(string memory name_, string memory symbol_)\n        ERC721(name_, symbol_)\n    {}\n\n    /// @inheritdoc\tERC165\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        virtual\n        override(ERC721, ERC2981Base)\n        returns (bool)\n    {\n        return super.supportsInterface(interfaceId);\n    }\n\n    /// @notice Mint one token to `to`\n    /// @param to the recipient of the token\n    /// @param royaltyRecipient the recipient for royalties (if royaltyValue > 0)\n    /// @param royaltyValue the royalties asked for (EIP2981)\n    function mint(\n        address to,\n        address royaltyRecipient,\n        uint256 royaltyValue\n    ) external {\n        uint256 tokenId = nextTokenId;\n        _safeMint(to, tokenId, '');\n\n        if (royaltyValue > 0) {\n            _setTokenRoyalty(tokenId, royaltyRecipient, royaltyValue);\n        }\n\n        nextTokenId = tokenId + 1;\n    }\n\n    /// @notice Mint several tokens at once\n    /// @param recipients an array of recipients for each token\n    /// @param royaltyRecipients an array of recipients for royalties (if royaltyValues[i] > 0)\n    /// @param royaltyValues an array of royalties asked for (EIP2981)\n    function mintBatch(\n        address[] memory recipients,\n        address[] memory royaltyRecipients,\n        uint256[] memory royaltyValues\n    ) external {\n        uint256 tokenId = nextTokenId;\n        require(\n            recipients.length == royaltyRecipients.length &&\n                recipients.length == royaltyValues.length,\n            'ERC721: Arrays length mismatch'\n        );\n\n        for (uint256 i; i < recipients.length; i++) {\n            _safeMint(recipients[i], tokenId, '');\n            if (royaltyValues[i] > 0) {\n                _setTokenRoyalty(\n                    tokenId,\n                    royaltyRecipients[i],\n                    royaltyValues[i]\n                );\n            }\n            tokenId++;\n        }\n\n        nextTokenId = tokenId;\n    }\n}\n"
  },
  {
    "path": "deploy/00_deploy_erc721.js",
    "content": "// deploy/00_deploy_my_contract.js\nmodule.exports = async ({ getNamedAccounts, deployments }) => {\n    const { deploy } = deployments;\n    const { deployer } = await getNamedAccounts();\n\n    await deploy('ERC721WithRoyalties', {\n        from: deployer,\n        args: ['ERC721WithRoyalties', '2981'],\n        log: true,\n    });\n};\nmodule.exports.tags = ['ERC721WithRoyalties'];\n"
  },
  {
    "path": "deploy/01_deploy_erc1155.js",
    "content": "// deploy/00_deploy_my_contract.js\nmodule.exports = async ({ getNamedAccounts, deployments }) => {\n    const { deploy } = deployments;\n    const { deployer } = await getNamedAccounts();\n\n    await deploy('ERC1155WithRoyalties', {\n        from: deployer,\n        args: ['ipfs://baseURI'],\n        log: true,\n    });\n};\nmodule.exports.tags = ['ERC1155WithRoyalties'];\n"
  },
  {
    "path": "deploy/02_deploy_erc721_contract_wide.js",
    "content": "// deploy/00_deploy_my_contract.js\nmodule.exports = async ({ getNamedAccounts, deployments }) => {\n    const { deploy } = deployments;\n    const { deployer } = await getNamedAccounts();\n\n    await deploy('ERC721WithContractWideRoyalties', {\n        from: deployer,\n        args: ['ERC721WithContractWideRoyalties', '2981'],\n        log: true,\n    });\n};\nmodule.exports.tags = ['ERC721WithContractWideRoyalties'];\n"
  },
  {
    "path": "hardhat.config.js",
    "content": "require('@nomiclabs/hardhat-ethers');\nrequire('@nomiclabs/hardhat-waffle');\nrequire('hardhat-deploy');\nrequire('hardhat-deploy-ethers');\nrequire('hardhat-tracer');\nrequire('@nomiclabs/hardhat-etherscan');\nrequire(\"hardhat-gas-reporter\");\n/**\n * @type import('hardhat/config').HardhatUserConfig\n */\nmodule.exports = {\n    solidity: {\n        version: '0.8.0',\n        settings: {\n            optimizer: {\n                enabled: true,\n                runs: 200,\n            },\n        },\n    },\n    namedAccounts: {\n        deployer: {\n            default: 0, // here this will by default take the first account as deployer\n        },\n    },\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"eip2981-example\",\n  \"version\": \"0.0.1\",\n  \"description\": \"EIP2981 implementation example\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"compile\": \"npx hardhat compile\",\n    \"test\": \"npx hardhat test\"\n  },\n  \"author\": \"simon fremaux (dievarump)\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"@nomiclabs/hardhat-ethers\": \"^2.0.2\",\n    \"@nomiclabs/hardhat-etherscan\": \"^2.1.3\",\n    \"@nomiclabs/hardhat-waffle\": \"^2.0.1\",\n    \"@openzeppelin/contracts\": \"^4.1.0\",\n    \"chai\": \"^4.3.4\",\n    \"ethereum-waffle\": \"^3.4.0\",\n    \"ethers\": \"^5.3.1\",\n    \"hardhat\": \"^2.4.0\",\n    \"hardhat-deploy\": \"^0.8.8\",\n    \"hardhat-deploy-ethers\": \"*\",\n    \"hardhat-gas-reporter\": \"1.0.4\",\n    \"hardhat-tracer\": \"*\"\n  }\n}\n"
  },
  {
    "path": "test/00_royalties_721.js",
    "content": "const { expect } = require('chai');\nconst { deployments, ethers } = require('hardhat');\n\nconst _INTERFACE_ID_ERC165 = '0x01ffc9a7';\nconst _INTERFACE_ID_ROYALTIES_EIP2981 = '0x2a55205a';\nconst _INTERFACE_ID_ERC721 = '0x80ac58cd';\n\ndescribe('ERC721WithRoyalties', () => {\n    let ERC721WithRoyalties;\n    let deployer;\n    let royaltiesRecipient;\n\n    const ADDRESS_ZERO = ethers.constants.AddressZero;\n\n    beforeEach(async () => {\n        [deployer, randomAccount, royaltiesRecipient] =\n            await ethers.getSigners();\n\n        await deployments.fixture();\n        ERC721WithRoyalties = await deployments.get('ERC721WithRoyalties');\n        erc721WithRoyalties = await ethers.getContractAt(\n            'ERC721WithRoyalties',\n            ERC721WithRoyalties.address,\n            deployer,\n        );\n    });\n\n    describe('Royalties', async () => {\n        it('has all the right interfaces', async function () {\n            expect(\n                await erc721WithRoyalties.supportsInterface(\n                    _INTERFACE_ID_ERC165,\n                ),\n                'Error Royalties 165',\n            ).to.be.true;\n\n            expect(\n                await erc721WithRoyalties.supportsInterface(\n                    _INTERFACE_ID_ROYALTIES_EIP2981,\n                ),\n                'Error Royalties 2981',\n            ).to.be.true;\n\n            expect(\n                await erc721WithRoyalties.supportsInterface(\n                    _INTERFACE_ID_ERC721,\n                ),\n                'Error Royalties 721',\n            ).to.be.true;\n        });\n\n        it('throws if royalties more than 100%', async function () {\n            const tx = erc721WithRoyalties.mint(\n                deployer.address,\n                royaltiesRecipient.address,\n                10001, // 100.01%\n            );\n\n            await expect(tx).to.be.revertedWith('ERC2981Royalties: Too high');\n        });\n\n        it('has the right royalties for tokenId', async function () {\n            await erc721WithRoyalties.mint(\n                deployer.address,\n                royaltiesRecipient.address,\n                250, // 2.50%\n            );\n\n            const info = await erc721WithRoyalties.royaltyInfo(0, 10000);\n            expect(info[1].toNumber()).to.be.equal(250);\n            expect(info[0]).to.be.equal(royaltiesRecipient.address);\n        });\n\n        it('can set address(0) as royalties recipient', async function () {\n            // 0.01% royalties\n            await erc721WithRoyalties.mint(deployer.address, ADDRESS_ZERO, 1);\n\n            const info = await erc721WithRoyalties.royaltyInfo(0, 10000);\n            expect(info[1].toNumber()).to.be.equal(1);\n            expect(info[0]).to.be.equal(ADDRESS_ZERO);\n        });\n\n        it('has no royalties if not set', async function () {\n            await erc721WithRoyalties.mint(\n                deployer.address,\n                royaltiesRecipient.address,\n                0,\n            );\n\n            const info = await erc721WithRoyalties.royaltyInfo(0, 100);\n            expect(info[1].toNumber()).to.be.equal(0);\n            expect(info[0]).to.be.equal(ADDRESS_ZERO);\n        });\n    });\n});\n"
  },
  {
    "path": "test/01_royalties_1155.js",
    "content": "const { expect } = require('chai');\nconst { deployments, ethers } = require('hardhat');\n\ndescribe('ERC1155WithRoyalties', () => {\n    let ERC1155WithRoyalties;\n    let deployer;\n    let randomAccount;\n    let royaltiesRecipient;\n\n    const ADDRESS_ZERO = ethers.constants.AddressZero;\n\n    beforeEach(async () => {\n        [deployer, randomAccount, royaltiesRecipient] =\n            await ethers.getSigners();\n\n        await deployments.fixture();\n        ERC1155WithRoyalties = await deployments.get('ERC1155WithRoyalties');\n        erc1155WithRoyalties = await ethers.getContractAt(\n            'ERC1155WithRoyalties',\n            ERC1155WithRoyalties.address,\n            deployer,\n        );\n    });\n\n    describe('Royalties', async () => {\n        it('throws if royalties more than 100%', async function () {\n            const tx = erc1155WithRoyalties.mint(\n                deployer.address,\n                0,\n                10,\n                royaltiesRecipient.address,\n                10001, // 100.01%\n            );\n\n            await expect(tx).to.be.revertedWith('ERC2981Royalties: Too high');\n        });\n\n        it('has the right royalties for tokenId', async function () {\n            await erc1155WithRoyalties.mint(\n                deployer.address,\n                0,\n                10,\n                royaltiesRecipient.address,\n                1000, // 10%\n            );\n\n            const info = await erc1155WithRoyalties.royaltyInfo(0, 100);\n            expect(info[1].toNumber()).to.be.equal(10);\n            expect(info[0]).to.be.equal(royaltiesRecipient.address);\n        });\n\n        it('can set address(0) as royalties recipient', async function () {\n            await erc1155WithRoyalties.mint(\n                deployer.address,\n                0,\n                10,\n                ADDRESS_ZERO,\n                1000,\n            );\n\n            const info = await erc1155WithRoyalties.royaltyInfo(0, 100);\n            expect(info[1].toNumber()).to.be.equal(10);\n            expect(info[0]).to.be.equal(ADDRESS_ZERO);\n        });\n\n        it('has no royalties if not set', async function () {\n            await erc1155WithRoyalties.mint(\n                deployer.address,\n                0,\n                10,\n                royaltiesRecipient.address,\n                0,\n            );\n\n            const info = await erc1155WithRoyalties.royaltyInfo(0, 100);\n            expect(info[1].toNumber()).to.be.equal(0);\n            expect(info[0]).to.be.equal(ADDRESS_ZERO);\n        });\n\n        it('each token has the right royalties when minting batch', async function () {\n            const ids = [0, 1, 2, 3];\n            const amounts = [10, 10, 10, 10];\n            const royaltyRecipients = [\n                randomAccount.address,\n                deployer.address,\n                ADDRESS_ZERO,\n                deployer.address,\n            ];\n            const royaltyValues = [1000, 800, 5000, 0];\n\n            await erc1155WithRoyalties.mintBatch(\n                deployer.address,\n                ids,\n                amounts,\n                royaltyRecipients,\n                royaltyValues,\n            );\n\n            for (const [index, id] of ids.entries()) {\n                const info = await erc1155WithRoyalties.royaltyInfo(id, 100);\n\n                expect(info[1].toNumber()).to.be.equal(\n                    royaltyValues[index] / 100,\n                );\n                if (info[1].toNumber() !== 0) {\n                    expect(info[0]).to.be.equal(royaltyRecipients[index]);\n                }\n            }\n        });\n    });\n});\n"
  },
  {
    "path": "test/02_royalties_721_contract_wide.js",
    "content": "const { expect } = require('chai');\nconst { deployments, ethers } = require('hardhat');\n\ndescribe('ERC721WithContractWideRoyalties', () => {\n    let ERC721WithContractWideRoyalties;\n    let deployer;\n    let royaltiesRecipient;\n\n    const ADDRESS_ZERO = ethers.constants.AddressZero;\n\n    beforeEach(async () => {\n        [deployer, randomAccount, royaltiesRecipient] =\n            await ethers.getSigners();\n\n        await deployments.fixture();\n        ERC721WithContractWideRoyalties = await deployments.get(\n            'ERC721WithContractWideRoyalties',\n        );\n        erc721WithRoyalties = await ethers.getContractAt(\n            'ERC721WithContractWideRoyalties',\n            ERC721WithContractWideRoyalties.address,\n            deployer,\n        );\n    });\n\n    describe('Contract wide Royalties', async () => {\n        it('has no royalties if not set', async function () {\n            await erc721WithRoyalties.mint(deployer.address);\n\n            const info = await erc721WithRoyalties.royaltyInfo(0, 100);\n            expect(info[1].toNumber()).to.be.equal(0);\n            expect(info[0]).to.be.equal(ADDRESS_ZERO);\n        });\n\n        it('throws if royalties more than 100%', async function () {\n            const tx = erc721WithRoyalties.setRoyalties(\n                royaltiesRecipient.address,\n                10001,\n            );\n            await expect(tx).to.be.revertedWith('ERC2981Royalties: Too high');\n        });\n\n        it('has the right royalties for tokenId', async function () {\n            await erc721WithRoyalties.setRoyalties(\n                royaltiesRecipient.address,\n                250,\n            );\n\n            await erc721WithRoyalties.mint(deployer.address);\n\n            const info = await erc721WithRoyalties.royaltyInfo(0, 10000);\n            expect(info[1].toNumber()).to.be.equal(250);\n            expect(info[0]).to.be.equal(royaltiesRecipient.address);\n        });\n\n        it('can set address(0) as royalties recipient', async function () {\n            await erc721WithRoyalties.setRoyalties(ADDRESS_ZERO, 5000);\n\n            await erc721WithRoyalties.mint(deployer.address);\n\n            const info = await erc721WithRoyalties.royaltyInfo(0, 10000);\n            expect(info[1].toNumber()).to.be.equal(5000);\n            expect(info[0]).to.be.equal(ADDRESS_ZERO);\n        });\n    });\n});\n"
  }
]