AccessControl suddenly giving error : TypeError: Member "toHexString" not found or not visible after argument-dependent lookup in type(library Strings)

I'm importing OZ AccessControl into my contract I created in Remix.

import "@openzeppelin/contracts/access/AccessControl.sol";

however the AccessControl import is underlined red with an error stating "TypeError: Member "toHexString" not found or not visible after argument-dependent lookup in type(library Strings)"

I've used OZ AccessControl before, same compiler version, and had no issue. This error just started happening out of the blue.

:1234: Code to reproduce

Create a .sol file in Remix and import OZ AccessControl, compiler version 0.8.9


:computer: Environment

Remix , sol compiler version 0.8.9

1 Like

Hi, welcome to the community! :wave:

Not sure for this, so could you please share the full source code at here?

Sure,

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/AccessControl.sol";

contract A {

    
}


1 Like

At least, it works for me.

1 Like

Probably a remix issue. Thank you

Hey @noodle_dev,

I tried it on my local remix and it happened as well. However, Remix caches dependencies, which will be resolving to a different utils/Strings.sol version without the .toHexString(address) function.

Try this:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;


import "@openzeppelin/contracts@4.8.0/access/AccessControl.sol";

contract A {

    
}

Note that using unversioned imports in Remix is not recommended because of this.
You can see and delete the cached dependencies in the remix file tree in case you want to remove them and start from scratch.

2 Likes

Thank you @ernestognw ! I cleared Remix .deps and recompiled and it works now. Thanks a ton!

1 Like