0

I am trying to import the ERC2981.sol from the OpenZeppelin contracts repository. In their GitHub page the royaltyInfo is a public function. But for some reason when I import it in my project, this function is external. This is the function (which is public):

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/5a75065659a65e65bb04890192e3a4bcb7917fff/contracts/token/common/ERC2981.sol#L43

But on Remix this is what it looks like and is external (inside .debs/npm/@openzeppelin/[email protected]/token/commonERC2981.sol)

enter image description here

And this is how I import it:

pragma solidity ^0.8.0;
import "@openzeppelin/[email protected]/token/common/ERC2981.sol";

And I am using 0.8.7+commit.e28d00a7 as a solidity compiler in Remix.

My question is: How can I resolve this issue? I can change the external to public in my hardhat deployment but I don't like to do this (changing manually).

1 Answer 1

1

It seems that this change has occurred within the last 3 weeks, and v4.5.0 was released on February 9th. Try using pre-release @4.6.0-rc.0 instead of @4.5.0 in the import statement. Be carful when using these pre releases as there can be bugs. You should be fine, but I would review the code that you are looking at in that GitHub before deploying to Mainnet.

pragma solidity ^0.8.0;
import "@openzeppelin/[email protected]/token/common/ERC2981.sol";
7
  • Yeah but this is also not inside the @4.6.0-rc.0 release. I guess they are waiting for "something"?!. I'll wait for an actual release.
    – MehmedB
    Apr 18, 2022 at 23:56
  • Try this import "@openzeppelin/contracts/token/common/ERC2981.sol" Apr 19, 2022 at 2:04
  • I believe that this will pull straight from the Github page with the current changes that have taken effect. Apr 19, 2022 at 2:05
  • It gets the latest release and this is not in the latest release. Maybe I can override this function but how?
    – MehmedB
    Apr 19, 2022 at 11:59
  • 1
    interesting, this worked for me. I'll look at it a bit more tomorrow. Apr 21, 2022 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.